Re: Playing Video with Django and html tag

2021-04-21 Thread Benjamin Schollnick
What web browser are you using?

I had to work my way around this as well, and it ended up being that I had to 
use:

RangedFileResponse module.
Name: django-ranged-response
Version: 0.2.0
Summary: Modified Django FileResponse that adds Content-Range headers.
Home-page: https://github.com/wearespindle/django-ranged-fileresponse
Author: Spindle
Author-email: jer...@wearespindle.com
License: MIT
Location: /Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages
Requires: django
Required-by: 

And I am using this wrapper, for the download:

def download(request, filename=None):
"""
Replaces new_download.  

This now takes http:///downloads/?UUID=

This fakes the browser into displaying the filename as the title of the
download.  

"""
# Is this from an archive?  If so, get the Page ID.
d_uuid=request.GET.get("UUID", None)
if d_uuid == None:
d_uuid=request.GET.get("uuid", None)

if d_uuid in ["", None]:
raise Http404

page = request.GET.get('page', None)
if page is None:
download = index_data.objects.filter(uuid=d_uuid,
 ignore=False,
 delete_pending=False)[0]
else:
print ("Attempting to find page %s in archive" % page)

print("\tDownloading - %s, %s" % (download.fqpndirectory.lower(),
  download.name))
  
movie = download.filetype.is_movie
return respond_as_inline(request,
 "%s%s%s" % (
 configdata["locations"]["albums_path"],
 os.sep,
 download.fqpndirectory),
 download.name,
 ranged=movie)


def respond_as_inline(request, file_path, original_filename, ranged=False):
# https://stackoverflow.com/questions/36392510/django-download-a-file
# 
https://stackoverflow.com/questions/27712778/video-plays-in-other-browsers-but-not-safari
# 
https://stackoverflow.com/questions/720419/how-can-i-find-out-whether-a-server-supports-the-range-header
filename = os.path.join(file_path, original_filename)
if os.path.exists(filename):
mtype, encoding = mimetypes.guess_type(original_filename)
if mtype is None:
mtype = 'application/octet-stream'

with open(filename, 'rb') as fh:
if ranged:
response = RangedFileResponse(request, file=open(filename, 
'rb'), as_attachment=False, filename=original_filename)
response["Content-Type"] = mtype
else:
response = HttpResponse(fh.read(), content_type=mtype)
response['Content-Disposition'] = 'inline; filename=%s'% 
original_filename
return response
else:
print("File not found")
raise Http404

For the web side..

{% if item.filetype.is_movie %}
 
  

{% endif %}

Hope that helps.  And yes, the python code is intended as a starting place, as 
it’s very specific to my implementation of a web gallery..
But I’m more than happy to try to help…

- Benjamin


> On Apr 21, 2021, at 8:10 PM, Thiago Luiz Parolin  
> wrote:
> 
> try using {% static.. to server your file.
> 
> ‪Em qua., 21 de abr. de 2021 às 19:44, ‫תמר בביוף‬‎  > escreveu:‬
> Hello everyone
>  :I try to enable a video tag in HTML like this 
> 
> 
> 
> :My problem is that the video does not run on Django, and looks like a black 
>  Running on html alone it works,  
> Does anyone know what the problem is? Is not a video tag enough when using 
> Django?  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/db9c1818-3312-45b4-a652-6a2dbc5bb688n%40googlegroups.com
>  
> .
> 
> 
> -- 
> Thiago Luiz Parolin
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CANbmKysnyHnW7yz6jL_rBS5xBrdroHmZNKTzn%2Bx2D2Vj0dy8aA%40mail.gmail.com
>  
> 

Re: Playing Video with Django and html tag

2021-04-21 Thread Thiago Luiz Parolin
try using {% static.. to server your file.

‪Em qua., 21 de abr. de 2021 às 19:44, ‫תמר בביוף‬‎ 
escreveu:‬

> Hello everyone
>  :I try to enable a video tag in HTML like this
> 
> 
> 
> :My problem is that the video does not run on Django, and looks like a
> black
>  Running on html alone it works,
> Does anyone know what the problem is? Is not a video tag enough when using
> Django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/db9c1818-3312-45b4-a652-6a2dbc5bb688n%40googlegroups.com
> 
> .
>


-- 
Thiago Luiz Parolin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANbmKysnyHnW7yz6jL_rBS5xBrdroHmZNKTzn%2Bx2D2Vj0dy8aA%40mail.gmail.com.


Playing Video with Django and html tag

2021-04-21 Thread תמר בביוף
Hello everyone
 :I try to enable a video tag in HTML like this 



:My problem is that the video does not run on Django, and looks like a 
black 
 Running on html alone it works,  
Does anyone know what the problem is? Is not a video tag enough when using 
Django?  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db9c1818-3312-45b4-a652-6a2dbc5bb688n%40googlegroups.com.