jazzband / django-embed-video

Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.
http://django-embed-video.rtfd.org
MIT License
382 stars 135 forks source link

HTML video/audio backend #57

Closed thijstriemstra closed 4 months ago

thijstriemstra commented 8 years ago

It looks like regular urls don't have a fallback to a <video> element that plays back the content. Would adding a native HTML video/audio backend (as a default for urls that end with .mp3, .mp4 etc) make sense (and be welcome or considered a plugin)?

yetty commented 8 years ago

New backend to provide <video> functionality sounds great. I'm looking forward to your pull request.

thijstriemstra commented 8 years ago

Cool, I've started working on it here. Just switched to tox for testing against multiple Django/Pythons locally, now on to the real code.

thijstriemstra commented 8 years ago

@yetty I suppose as long as the URL is correct (verified by django's urlvalidator in the model or form field) we will try the 'BasicMediaBackend' (what I called it for now, better suggestions for a name are welcome). This because a media URL doesn't necessarily have an extension (e.g. http://foo.com/myvideostream). Should the code and thumbnail url always return None? Maybe there should be a audio and video backend, so the user can decide if a certain field uses a specific backend (maybe a backend keyword with a dotted path to the backend)?

yetty commented 8 years ago

There should be at least some checks, that given URL is valid. I guess the best solution would be to check, if server gives correct Content-Type in response. Based on content type it would be used the propriate backend — video or audio.

For example if you use the video from http://www.quirksmode.org/html5/tests/video.html, the headers are

curl -XHEAD -i http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4
HTTP/1.1 200 OK
Date: Mon, 18 Apr 2016 11:02:40 GMT
Server: Apache/2.2.22 (Debian)
Last-Modified: Wed, 16 Feb 2011 14:20:59 GMT
ETag: "1d670c9-5416d8-49c66fd774813"
Accept-Ranges: bytes
Content-Length: 5510872
Content-Type: video/mp4

so video backend should be used.

I suggest the naming Html5VideoBackend and Html5AudioBackend.

thijstriemstra commented 8 years ago

@yetty I've opened #58 with a backend that works here but there are still some quirks:

Any feedback is welcome.

yetty commented 8 years ago

Thanks for all the spelling and grammar corrections! :)

I suggest next improvements:

thijstriemstra commented 8 years ago

Updated the PR @yetty

For video I would use the default_size. For audio there is no need of sizes.

I'm not sure how to change the default_size on a custom backend?

I've added some real urls. It seems to succeed on all builders except Django 1.5 and 1.6 on Python 3.4 (?!).

Also added the templates. Coverage remains the same. Leaving the initial data for the example up to you, I couldn't get it to work with Django 1.9.

mgrdcm commented 8 years ago

@thijstriemstra Since we're both now maintainers on this, would you be OK with me reviewing your changes (starting with this one), and you review mine should I have any?

thijstriemstra commented 8 years ago

Sounds good @mgrdcm!

thijstriemstra commented 8 years ago

Let me change the title of this ticket to HTML5 video or something. Video.js support can be integrated later.

SalahAdDin commented 7 years ago

:+1: