Re: [media] adding autoplay requirements to requirements doc

On Wed, Apr 20, 2011 at 5:41 PM, Philip Jägenstedt <philipj@opera.com> wrote:
> On Wed, 20 Apr 2011 04:52:08 +0200, Silvia Pfeiffer
> <silviapfeiffer1@gmail.com> wrote:
>
>> On Tue, Apr 19, 2011 at 8:58 PM, Philip Jägenstedt <philipj@opera.com>
>> wrote:
>>>
>>> On Tue, 19 Apr 2011 12:00:38 +0200, Silvia Pfeiffer
>>> <silviapfeiffer1@gmail.com> wrote:
>>>
>>>> On Tue, Apr 19, 2011 at 6:29 PM, Philip Jägenstedt <philipj@opera.com>
>>>> wrote:
>>>>
>>>>> Possible solutions here are:
>>>>>
>>>>> 1. Requiring explicit approval for all media playback, with the
>>>>> possibility
>>>>> of remembering approval per domain.
>>>>>
>>>>> 2. Exposing a list of all media elements associated with a document to
>>>>> scripts so that extensions could find and pause all media elements.
>>>>> Currently this is not possible because elements can be created by
>>>>> scripts
>>>>> and set to play without being inserted into a document, so e.g.
>>>>> document.querySelector('audio,video') does not find them.
>>>>
>>>> These are both good ideas. Would it be possible to get them through
>>>> plugins? Or do they need a JS API?
>>>
>>> I think the first really needs to be a browser feature to be effective,
>>> similar to pop-up blockers. Extensions could emulate it to some extent,
>>> but
>>> could not create a UI to list all of the blocked sites, for example.
>>>
>>> The second should be possible using scripts, but it takes some effort to
>>> intercept everything that could possibly create new media element. For
>>> createElement, one would have to do something like this:
>>>
>>> (function() {
>>>  var cE = document.createElement;
>>>  document.createElement = function() {
>>>   var elm = cE.apply(document, arguments);
>>>   if (elm instanceof HTMLMediaElement) {
>>>     /* keep track of this element */
>>>   }
>>>   return elm;
>>>  };
>>> })();
>>>
>>> Similar things would have to be done to innerHTML, outerHTML and any
>>> other
>>> properties that can create new elements.
>>>
>>> A very serious downside of this approach is that just by keeping track of
>>> the elements, they can never be garbage collected, so all media elements
>>> would be kept alive as long as the creating document is alive.
>>> (ECMAScript
>>> doesn't have weak references.)
>>>
>>> In summary, this is something best done as a browser feature.
>>
>> In either case, none of this influences the HTML spec, right?
>>
>> Also, all these solutions can do is catch any call of play()? So it
>> they would be general control of playback rather than just the initial
>> autoplay? Is this really something we want to require for
>> accessibility reasons? It may be going just a tad too far IMHO.
>
> If it's a problem that media starts playing without user consent then it's
> not enough to disable autoplay, as there will certainly be sites that use
> scripts to start playing.

Yes, we agreed on that, too. But we didn't see a way to catch the
script-created autoplays in a simple and reliable way.


> The spec doesn't need to change for it to be
> possible to do option 1. For option 2 it would have to expose a list of all
> live media elements, but I think that's not such a great idea after all.

Yeah, I'd leave it to UAs.

Cheers,
Silvia.

Received on Wednesday, 20 April 2011 10:09:00 UTC