Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can HTML5 video preload be forced on iOS devices?

I've found plenty of sites and references that confirm that on Android and iOS mobile devices, HTML5 video preload='auto' tags are deliberately ignored and the browsers wait for the user to manually press the play button.

Is there any way that this behaviour can be overruled?

Our situation is that we are planning to have iPads running on a closed intranet WiFi system, where cell network data charges will definitely not be an issue. We have video files which need to automatically skip to a specific play position as soon as the page is loaded. It works brilliantly on Chrome on Windows, Linux or MacOS, but iOS is having none of it.

Is there a setting in iOS or Android which allows 'preload' to behave like it does on other platforms?

Alternatively, I've got JavaScript and jQuery going on on the pages. Are there any calls that can persuade the browser to preload the video even if preload='auto' doesn't?

I've put a test page up at http://www.stuartbruce.co.uk/editreader/javascript_video_test to show what happens. On Chrome, on every platform except iOS, the videos automatically skip to shot 3. On iOS, nothing happens.

Apple's own line on the subject is here: User Control of Downloads Over Cellular Networks but the fact that they have called it "User Control of Downloads" implies that this is something the user could optionally change. However, I can't see any evidence of that. Is it possible? Can a user or an iPad be 'opted in' to allow preload='auto' to work properly?

like image 432
Stuart Bruce Avatar asked Jan 17 '16 11:01

Stuart Bruce


Video Answer


1 Answers

Based on the update/info below you should be able to do this provided you have the muted attribute set:

video.play();
video.addEventListener('canplay', function() {
    this.currentTime = 5;
});

New Policies for iOS article indicates:

By default, WebKit will have the following policies:

  • elements will now honor the autoplay attribute, for elements which meet the following conditions:
    • elements will be allowed to autoplay without a user gesture if their source media contains no audio tracks.
    • elements will also be allowed to autoplay without a user gesture.
    • If a element gains an audio track or becomes un-muted without a user gesture, playback will pause.
    • elements will only begin playing when visible on-screen such as when they are scrolled into the viewport, made visible through CSS, and inserted into the DOM.
  • elements will pause if they become non-visible, such as by being scrolled out of the viewport.
  • elements will now honor the play() method, for elements which meet the following conditions:
  • elements will be allowed to play() without a user gesture if their source media contains no audio tracks, or if their muted property is set to true.
  • If a element gains an audio track or becomes un-muted without a user gesture, playback will pause. elements will be allowed to play() when not visible on-screen or when out of the viewport.
  • video.play() will return a Promise, which will be rejected if any of these conditions are not met.
  • On iPhone, elements will now be allowed to play inline, and will not automatically enter fullscreen mode when playback begins.
  • elements without playsinline attributes will continue to require fullscreen mode for playback on iPhone.
  • When exiting fullscreen with a pinch gesture, elements without playsinline will continue to play inline.
like image 58
Ronnie Royston Avatar answered Oct 10 '22 10:10

Ronnie Royston