One W3C specification which seems to have slipped below most people’s radar is Media Fragments 1.0, which moved to Candidate Recommendation status in December last year. Media Fragments is a syntax which extends the URLs of media files so that only selected portions are made available to the user; let me explain that further with a couple of examples.
Each Fragment type is known as a Dimension, and the Temporal Dimension sets a start and end point on media which is playable, such as audio and video. For example, if you had an audio file which you wanted to play just a small piece of, you would use something like this:
The t represents time, and the two figures are values in seconds to play from and to — in this case, the section between 4 and 12 seconds. Firefox 9.0+, Safari 5.2 and Chrome have implemented this already, so if you have one of those browsers here’s a demo of the Temporal Dimension on a video file. When the page has loaded the play button starts the video at the 4s mark and ends it on 12s. Note that the user can move the timeline control around to play any portion of the video they wish.
Another use for Media Fragments is on the Spatial Dimension — that is, only displaying a portion of a media file on screen. As an example, this is how you could extend an image:
The xywh stands for (respectively) the x and y co-ordinates, plus height and width; in this case the portion of the image that would be displayed would be 100px wide by 40px high, starting at a point 10px from the left and 10px from the top. As I’m sure you can imagine, this could be immensely useful for image sprites. Note that by default those values are in pixels, but you can use percentages if you prefer:
Of the other two dimensions, the first is for pulling tracks from media containers (such as the audio track of a video file) — this is the Track Dimension:
And if the source file contains named temporal fragments you can pull those using their ID value — this is the ID Dimension:
If you’re keen to start playing around with Media Fragments, Google developer Thomas Steiner has written the mediafragments.js library which parses URLs for known Dimensions and outputs the result as JSON.