Re: Media: Question about autoplay (video in browsers)

On Jan 27, 2011, at 12:06 PM, Eric Carlson wrote:

> 
> On Jan 27, 2011, at 10:39 AM, Philip Jägenstedt wrote:
> 
>> 
>> Short answer: Yes, it's possible.
>> 
>> I've recently added a user preference to Opera to disable autoplay, and this should be in a not too distant release of our desktop browser. If it turns out that it's common with sites that use script to force autoplay, then it's possible to go further. Specifically, one could use the same techniques that are used for pop-up blockers to see if the play() request was from user interaction or a background script. If isn't from direct user interaction, one could ask the user to explicitly allow the media to play, perhaps remembering the choice for the site.
>> 
>> However, this kind of thing would be an opt-in setting, since we don't want to bother users with lots of dialogs by default.
> 
>  iOS devices have this restriction - playback of a <video> or <audio> element can only be triggered in response to a user gesture (like pop-up blockers). This has caused no end of bug reports because it is impossible to differentiate script originated "auto play" from playback triggered by a script after a delay, eg. 
> 
> 	onclick= "setTimeout(function(){ video.play() }, 200)"
> 
> or in response to another event, eg. to start playback after something else happens:
> 
> 	button.addEventListener('webkitAnimationEnd', function (){ video.play) }, false);
> 
>  Neither of these is a much of an edge case as you might think, I get bug reports all the time about web sites where <video> "doesn't work on the iPhone" because they use script to trigger playback.
> 
  I meant to add that one real danger with this kind of change is that many (most?) developers won't test with the setting enabled, so audio and video on their pages won't just not auto-play - it won't play at all.

eric

Received on Thursday, 27 January 2011 22:13:17 UTC