HTML and CSS Reference
In-Depth Information
ments, the main video, is created with a controls attribute. Clicking the play button on the
video also triggers a play on the other two resources. Clicking on the pause button pauses all
three resources:
<video poster="some.png" controls mediagroup="altogethernow">
<source src="videofile.mp4" type="video/mp4" />
<source src="videofile.ogg" type="video/ogg" />
</video>
<video poster="sign.png" mediagroup="altogethernow">
<source src="videofilesign.mp4" type="video/mp4" />
</source src="videofilesign.ogg" type="video/ogg" />
</video>
<audio mediagroup="altogethernow">
<source src="audiofile.mp3" type="audio/mp3" />
<source src="audiofile.ogg" type="audio/ogg" />
</audio>
Among other use cases is that of creating a picture-in-picture effect by scaling one video and
overlaying it on the other, and then adding the controls attribute to the larger, primary video.
There are many possible uses for this type of functionality and, just as with a single resource,
you can use JavaScript to control the media controller (and hence the playback of the entire
group of media resources).
The MediaController object provides an interface for accessing the media controller in script.
It supports two methods:
play
Sets the paused attribute to false and causes playback to resume on all slaved media re-
sources.
pause
Sets the paused attribute to true and causes playback to pause on all slaved media re-
sources.
The MediaController methods are similar to the methods for HTMLMediaElement described
in Chapter . The difference lies in the fact that more than one media resource is controlled by
an individual action.
The properties for the MediaController are also very similar to those listed for the HTMLMe-
diaElement in Table 5 in Chapter , as shown in Table 7 . Again, the primary difference is that
the property's value isn't dependent on the state of one media resource, but a group of media
resources. In the HTML5 specification, all of the media resources controlled by a media con-
troller are known as slaved media resources.
Search WWH ::




Custom Search