Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add two new file field formatters (which then can be used as file formatters):
- HTML5 audio
- HTML5 video
These two field formatters should have the following options:
- Output field values as: [multiple audio tags|multiple sources]
- The rest of the options that audio and video tags support
We should also add two additional theme functions, like theme_file_audio() and theme_file_video() to do the work of the actual output.
Comment | File | Size | Author |
---|---|---|---|
#37 | 1748952-audio-video-html5.patch | 12.64 KB | Dave Reid |
#37 | interdiff.txt | 12.62 KB | Dave Reid |
#36 | interdiff.txt | 667 bytes | saltednut |
#36 | file_entity-audio_video_formatters-1748952-36.patch | 13.51 KB | saltednut |
#33 | file_entity-audio_video_formatters-1748952-33.patch | 13.28 KB | sylus |
Comments
Comment #1
erik.erskine CreditAttribution: erik.erskine commentedComment #2
erik.erskine CreditAttribution: erik.erskine commentedAdded an initial version of audio element formatter. Still to add support for more attributes, and a video formatter. Comments welcome
Comment #3
erik.erskine CreditAttribution: erik.erskine commentedHere is an extension of the patch in #2 that adds a video formatter.
These formatters also ignore any files that are not of the appropriate type.
Comment #4
slashrsm CreditAttribution: slashrsm commentedI installed it, tested both and and it basically works. The biggest problem I notices is with configuration for tags/sources. It seems like formatter uses tags (one file per tag) even if I selected "sources" option.
I think you should handle default settings for 'multiple_file_behaviour' here.
It would be nice to display entire configuration in summary, not only one.
Why did you add m4a here? Was it intentionally or by a mistake?
It is also almost impossible for an ordinary user to start video/audio, if you decide to hide controls. Adding support for autoplay would help in this case. It would be nice to support all attributes of , and anyway (autoplay, preload, width, height, type (file's mimetype) ...).
http://www.w3schools.com/html5/tag_video.asp
http://www.w3schools.com/html5/tag_audio.asp
http://www.w3schools.com/html5/tag_source.asp
Comment #5
erik.erskine CreditAttribution: erik.erskine commentedThanks for the feedback, slashrsm.
Here is a new patch:
- test for settings that don't exist and provide suitable defaults
- I've added some more options - autoplay/loop for audio, autoplay/loop/muted/width/height for video.
- removed the new m4a extension - indeed that was a mistake.
Comment #6
RobW CreditAttribution: RobW commentedHave you checked out http://drupal.org/project/html5_media yet? It seems like there could be a lot of overlap here, maybe some code that could be re-used.
Comment #7
Dave ReidWe are shooting for a much simpler alternative that html5_media that does not include a large library. We just want native audio and video tags as formatters/theme functions.
Comment #8
slashrsm CreditAttribution: slashrsm commentedLooks OK now. Thank you for the great patch.
I'd say that it would be nice to have tests for this. I am aware that there are not many in file_entity, but I think we should start adding them. When a new feature is added it is IMO a great time for that.
Comment #9
RobW CreditAttribution: RobW commentedIt would be nice to have the markup provided by tpls, which are generally easier for front end developers to work with. I'll see if I can add them sometime over the next two weeks.
Comment #10
quicksketchIt seems to me that this request is a bit out of scope for this project. I haven't had much involvement with it, but based on this module's description, I wouldn't expect File Entity module to be providing functionality beyond its stated purpose of making files fieldable. Especially considering HTML5 video and audio tags aren't universally supported, and Firefox's ongoing resistance to MP3 licensing, HTML5 audio and video tags just aren't universal enough to be useful for most sites. I would expect to have to install a module that provides an HTML5/Flash based player for either audio or video for the time being. If File Entity also provides formatters for video/audio, it's just going to make things confusing that we'll always have HTML5-only formatters that we'll need to ignore.
Comment #11
travist CreditAttribution: travist commentedI agree with quicksketch. If you don't have the fallbacks in place, then the solution is somewhat incomplete. I have done very similar work to this patch in the module http://drupal.org/project/html5_media as RobW pointed out (which I just updated with the latest version of media player), so you can definitely look at that as a reference if you would like. But as Dave pointed out, adding a huge library into the project may not be ideal.
Another alternative is to implement something similar to what Video For Everybody does where it includes an image placeholder inside of the tags if they are not supported. I am thinking that this may be best for this module since you do end up with some form of fallback (even though it sucks), but you are also not forcing people to download a large media player library with this module.
Comment #12
Devin Carlson CreditAttribution: Devin Carlson commentedMarked #1496528: Rich media display with <video> and <audio> HTML5 elements. as a duplicate.
Comment #13
sylus CreditAttribution: sylus commentedNew patch against latest dev
Comment #14
Devin Carlson CreditAttribution: Devin Carlson commentedComment #15
queenvictoria CreditAttribution: queenvictoria commentedPatch in #13 works well for me.
FWIW I think the Flash question (alternate rendering for browsers that don't support HTML5 Video/Audio tags) should be handled elsewhere. Its a layer on top of functional HTML (like animated menus for example) rather than core functionality. I guess that is progressive degradation rather than enhancement. In my opinion we should be providing some file display markup (as it becomes available) rather than rendering an "I don't know what to do with this file". Just my 2c.
Comment #16
aaron CreditAttribution: aaron commentedI still waffle a bit on this issue but I agree in large part to what quicksketch says. On the other hand, it would be nice to have video and audio support out of the box. Additionally, this might help nudge html5 adoption, if only a very little bit. I wonder if we might consider moving this patch over to the media module.
Comment #17
slashrsm CreditAttribution: slashrsm commentedI agree with aaron. I am convinced that we need to provide and formatters by default. Once you have that it is relatively easy to provide FLASH degradation (enable mediaelement.module and enable it site-wide).
I am voting for inclusion of this formatters in file_entity/media and writing some proper online docs on how to use them + list of modules that provide degradation.
Comment #18
sylus CreditAttribution: sylus commentedAgree with aaron + slashrsm.
Comment #19
aaron CreditAttribution: aaron commentedThis looks great and works great.
Comment #20
Devin Carlson CreditAttribution: Devin Carlson commentedWhile I'm +1 for including basic support for and in File entity, I'm not sure about adding it to 7.x.
Since Drupal 7 is XHTML+RDFa 1.0 out of the box are we assuming that, if they want to use the formatters, everyone is okay with either File entity generating invalid markup (and not working at all in older browsers, such as IE6-8 which are supported by Drupal Core) or running an HTML5 theme/changing html.tpl.php themselves?
I've got the same thoughts about leaving #1871792: Add support for mapping certain fields to HTML5 data- attributes out of File entity until 8.x.
Otherwise #13 looks great.
Comment #21
douggreen CreditAttribution: douggreen commentedRerolled
Comment #23
douggreen CreditAttribution: douggreen commentedI don't know why the patch failed testing, it's complaining about entity_file.module not existing, that seems like a failure on the testbot!?
Attached is a slightly updated patch, which includes {#2046467], and changes 'else if' to 'elseif'.
Comment #24
slashrsm CreditAttribution: slashrsm commentedComment #26
douggreen CreditAttribution: douggreen commentedupdated patch after #2046467: Fix comparison that uses = instead of ==
Comment #27
Devin Carlson CreditAttribution: Devin Carlson commentedComment #28
mollyavalon CreditAttribution: mollyavalon commentedWorks fine for both audio & video
Comment #29
Dave ReidIs there any way to hide the 'multiple_file_behaviour' options when being configured as a file formatter as compared to a field formatter? It doesn't make much sense to show it in that case? If it's not possible, that's ok - let's just file it as a followup task.
Comment #30
genjohnson CreditAttribution: genjohnson commentedI've changed the spelling of "behaviour" to "behavior" based on the coding standards.
Comment #31
Devin Carlson CreditAttribution: Devin Carlson commentedComment #32
Dave ReidHrm, guessing this
<div>
wasn't exactly meant to be in this patch?Comment #33
sylus CreditAttribution: sylus commentedThat was my bad :(
Attaching a patch without the associated div. My apologies!
Comment #34
Dave ReidHas my question in comment #29 been answered?
At first glance it doesn't look like the patch does anything to handle this yet?
Comment #35
aaron CreditAttribution: aaron commentedLooks that way to me as well.
Comment #36
saltednutI believe we can just disable this based around whether or not
$field
returns NULL on the settings forms. Patch and interdiff attached.Comment #37
Dave ReidI made some tweaks to #36 while testing:
<audio>
and<video>
tags in the summary itself.I might follow-up with some cleanups to the 'multiple_file_behavior' handling and form elements, but this is good for now.
Comment #39
Devin Carlson CreditAttribution: Devin Carlson commented#37 failed testing because it has just been committed!
http://drupalcode.org/project/file_entity.git/commit/6cb80eb
Comment #41
Albert Volkman CreditAttribution: Albert Volkman commentedSorry to resurrect an old post... However, I see that this is a field formatter. Is there a form element as well so that I can use this in a custom form? Basically I'm assuming it'd be a video/audio field, set to unlimited? If there's another ticket for this request, please kindly point me in that direction. Thanks so much.