I'm trying to use a short video loop as a background in a block. By using the display attributes Autoplay, Loop and Muted, I can get this feature working well in most desktop browsers. But Safari iOS requires the presence of the playsinline attribute to play these videos in the background. Like so:
<video autoplay loop muted playsinline>
<source src="image.mp4">
</video>
Is it possible to add a plasysinline checkbox to the format settings form under Manage Display, then pass that setting to theme_file_entity_file_video?
As an alternative, is there a hook for altering video fields? (hook_file_formatter_FORMATTER_view perhaps) And if so, where can I find documentation for it?
Some info on the playsinline attribute.
https://webkit.org/blog/6784/new-video-policies-for-ios/
Thanks,
John
Comments
Comment #2
johnodonnell@mac.com commentedAttached is a patch that I think addresses the issue. It adds a `playsinline` attribute to theme_file_entity_file_video() and any place in the admin where the value needs to shown, edited or stored to settings.
Comment #3
johnodonnell@mac.com commentedJust ran this patch against file_entity 7.x-2.0 and it appears to be working fine.
Comment #4
teknikqaRerolling patch against 7.x-2.x-dev.
Thanks @johnodonnell. The patch works for me.
Could use another set of eyes.
Comment #5
joseph.olstadThis looks like useful optional functionality. I'd like another review or two if possible.
Thanks
Comment #6
teknikqaI've been successfully running this patch on a couple of websites. There have been no issues.
Would be great to have this as part of the next release.
Comment #8
joseph.olstadwhat does playsinline do ?
Comment #9
teknikqaFrom MDN -
Mobile browsers allow videos to be autoplayed only if they are muted. iOS by default will play videos in fullscreen. To be able to play inline, you need to set the playsinline attribute. This is extremely useful for websites that play videos in the background.
The alternative is to use a GIF, but a video is lot smaller.
Comment #10
digitalfrontiersmediaI just ran into this with a site that was upgraded to D8 and using file_entity. I started using Media in Core, and there is a separate patch being worked out for this there (#3046152: Add playsinline option to Video media file formatter), but it seems like it's geared for D8.8 and didn't work for me. Attached is a D8 patch that got autoplay working for me on iOS devices, but it's possible it's not as extensive as it should be based on some of the things I see in the D7 patch in #4.
Either way, the D8 branch shouldn't be forgotten here.
Comment #11
jpschroeder commentedDigitalFrontiersMedia – I just updated the patch for the other issue (#3046152: Video media needs playsinline & muted options). It was broken for >= 8.7.2, but it should work now.
Comment #15
joseph.olstad