[whatwg] <source> media attribute behavior, static or dynamic ?
Ian Hickson
ian at hixie.ch
Thu May 10 16:08:17 PDT 2012
On Thu, 10 May 2012, Paul Adenot wrote:
> >
> > As far as I can tell, the behaviour here is strictly and unambiguously
> > defined, leaving only one possible interpretation, so it's not clear
> > to me how to make it less ambiguous. Could you elaborate on what
> > interpretations of the spec you think are possible?
>
> We have two possible interpretations, here :
> 1. If the environment of the user changes, then the source of the video has to
> change according to the different child source element and their respective
> media queries.
>
> [...]
>
> Support for the first interpretation :
>
> > Dynamically modifying a source element and its attribute when the
> > element is already inserted in a video or audio element will have no
> > effect.
>
> We are never modifying the source elements, we are only relying on the media
> attribute of those elements. We therefore can't conclude that by having a
> read-only behavior, the media that is currently playing will not change.
The spec says _exactly_ what it means. You do not need to ever read
between the lines. Here, the paragraph only says that modifying the
attribute has no effect. It doesn't say anything else. It doesn't say that
if the environment changes, anything happens. It doesn't say that if the
phase of the moon is "full", that the video should play backwards.
Presumably you haven't interpreted it to suggest that you should play
backwards in a full moon. :-) The same applies to anything else.
Furthermore, the paragraph you quote above is non-normative. The paragraph
doesn't say anything with a "must", it doesn't define any terms. It
therefore can not in any way affect what an implementation does.
> Support for the second interpretation :
>
> > To change what is playing, just use the src attribute on the media
> > element directly, possibly making use of the canPlayType() method to
> > pick from amongst available resources.
This paragraph is not normative either. Again, it has no conformance
criteria ("must") and doesn't define anything.
Please, as an implementor, ignore everything that isn't a conformance
criteria.
> The "just" word here seems to imply modifying the src attribute of the
> audio or video parent is the only way to change the media that is
> playing. By deduction, media attributes of children source elements
> cannot change a the source that is currently playing.
If at any time you are finding yourself worrying about what hte spec
implies, or deducing anything about what the spec means, stop, you don't
ever have to do that. :-)
The only place in the spec that is in any way affected by the "media"
attribute on the <source> element (other than the .media IDL attribute) is
step 6, substep 6, of the "resource selection algorithm". The only time,
therefore, that you should ever be affected by the media="" attribute, is
when you reach that step in your implementation. There is nothing that
causes that to happen when the environment changes.
HTH,
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list