Media Fragments

On occasion you may want to play only a portion of a media file, but you don’t want to edit the clip manually. You can do this with JavaScript, as you’ll see in the next section, but many browsers also support the Media Fragments URI. This information is appended to the URL of the media file, which sets certain parameters on it. To set a time range, as in this notional example, you would use something like this:

<audio src="foo.oga#t=4,8"></audio>

The #t notation is a shortcut for a time range, with the two comma-separated values after it representing the start time and end time in seconds. In this case, the clip would play for between four and eight seconds. You can leave out either number; leaving out the first means “play from ...

Get The Modern Web now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.