This is a bit of a special Simplequiz this week. Simon Pieters (@zcorpan), who works on multimedia QA for Opera and is one of those working on the HTML5 spec, asked us to run a quiz that would help the spec writers decide on a new aspect of the language. What power you wield, gentle reader! Over to Simon…
This SimpleQuiz is a bit different to previous SimpleQuizzes, since we’d like to use the result of this quiz to inform a design decision in the HTML5 spec. The question concerns how to mute a video in markup, and how this should be reflected in the DOM.
The use case is wanting to have multiple videos playing at once, but with all but one being muted at a time. This can be done today by setting .muted = true
with script, but it would be more convenient to be able to mute with markup.
The .muted
IDL attribute reflects the user setting of muted for the video element — if the user clicks “mute” in the native video controls, then the value of .muted
changes, and vice versa. It would make sense for the browser to remember the mute setting for individual video elements on page reload (or later visit), so that the user doesn’t have to re-mute them.
This is where it starts to get hairy if we introduce a content attribute for muting. (Note that code fragments below aren’t real code, just suggestions.)
We could introduce muted=""
which is reflected by .muted
(i.e. if one changes, so does the other), but this would cause the DOM to mutate during parsing if the remembered setting doesn’t match the markup, i.e. you would get muted=""
to appear in the DOM if the video is muted by the user even though there was no such attribute in the markup, which could confuse your scripts or style sheets if it’s not what you expected to happen.
We could introduce defaultmuted=""
which is reflected by .defaultMuted
, and just let the user setting change .muted
, but defaultmuted=""
is a bit long and ugly in markup.
We could have muted=""
which is reflected by .defaultMuted
and let the user setting change .muted
, but it might be confusing for some people. On the other hand it is consistent with <input value>
and .defaultValue
.
What do you think? Which is the best option? Is there another option that is better than any of the above?
HTML5 Simplequiz #3: how to mute a video originally appeared on HTML5 Doctor on October 15, 2010.