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

johnodonnell@mac.com created an issue. See original summary.

johnodonnell@mac.com’s picture

Attached 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.

johnodonnell@mac.com’s picture

Just ran this patch against file_entity 7.x-2.0 and it appears to be working fine.

teknikqa’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new3.75 KB

Rerolling patch against 7.x-2.x-dev.

Thanks @johnodonnell. The patch works for me.

Could use another set of eyes.

joseph.olstad’s picture

This looks like useful optional functionality. I'd like another review or two if possible.
Thanks

teknikqa’s picture

Status: Needs review » Reviewed & tested by the community

I'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.

The last submitted patch, 2: playsinline_attribute_video_fields-2835631-2.patch, failed testing. View results

joseph.olstad’s picture

what does playsinline do ?

teknikqa’s picture

From MDN -

playsinline: A Boolean attribute which indicates that the video is to be played "inline", that is within the element's playback area. Note that the absence of this attribute does not imply that the video will always be played in fullscreen.

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.

digitalfrontiersmedia’s picture

I 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.

jpschroeder’s picture

DigitalFrontiersMedia – 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.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.