The seekable
read-only property of the HTMLMediaElement
returns a TimeRanges
object that contains the time ranges that the user is able to seek to, if any.
var seekable = audioOrVideo.seekable;
A TimeRanges
object.
This example will listen for audio data to be loaded for the element `example`. It will then check if at least the current playback position has been loaded. If it has, the audio will play.
<audio id="example" preload="auto"> <source src="sound.ogg" type="audio/ogg" /> </audio>
var obj = document.getElementById('example'); obj.addEventListener('loadeddata', function() { if(obj.readyState >= 2) { obj.play(); } });
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'HTMLMediaElement' in that specification. | Living Standard | No change from HTML5 |
HTML5 The definition of 'HTMLMediaElement' in that specification. | Recommendation | Initial definition. |
Media Source Extensions The definition of 'HTMLMediaElement extensions, like for seekable' in that specification. | Candidate Recommendation | Specifies a new algorithm for returning the seekable time range of a media element whose source is a MediaSource object. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 8.0 (8.0) | 9 | ? | ? |
Using seekable along with MSE | 23 | (Yes) |
25.0 (25.0)[1] 42.0 (42.0) | 11[2] | 15 | 8 |
Feature | Android | Edge | Firefox Mobile (Gecko) | Firefox OS (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 8.0 (8.0) | (Yes) | ? | ? | ? |
Using seekable along with MSE | 4.4.4 | (Yes) | No support | No support | 11 | 30 | No support |
[1] Available after switching the about:config
preference media.mediasource.enabled
to true
. In addition, support was limited to a whitelist of sites, for example YouTube, Netflix, and other popular streaming sites. The whitelist was removed and Media Source Extensions was enabled by default in 42+ for all sites.
[2] Only works on Windows 8+.
HTMLMediaElement
.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seekable