Correct a bug in firefox regarding seeking before play
Firefox doesn't allow you to seek until 'canplay' is fired and doesn't fire canplay until after playback has begun. As a result, seeking to the right point in a live stream requires setupFirstPlay to wait for 'canplay' and check that the readyState signifies that we can finally seek.
Showing
1 changed file
with
7 additions
and
2 deletions
... | @@ -165,6 +165,8 @@ videojs.HlsHandler.prototype.src = function(src) { | ... | @@ -165,6 +165,8 @@ videojs.HlsHandler.prototype.src = function(src) { |
165 | } | 165 | } |
166 | this.playlists = new videojs.Hls.PlaylistLoader(this.source_.src, this.options_.withCredentials); | 166 | this.playlists = new videojs.Hls.PlaylistLoader(this.source_.src, this.options_.withCredentials); |
167 | 167 | ||
168 | this.tech_.on('canplay', this.setupFirstPlay.bind(this)); | ||
169 | |||
168 | this.playlists.on('loadedmetadata', function() { | 170 | this.playlists.on('loadedmetadata', function() { |
169 | oldMediaPlaylist = this.playlists.media(); | 171 | oldMediaPlaylist = this.playlists.media(); |
170 | 172 | ||
... | @@ -422,7 +424,11 @@ videojs.HlsHandler.prototype.setupFirstPlay = function() { | ... | @@ -422,7 +424,11 @@ videojs.HlsHandler.prototype.setupFirstPlay = function() { |
422 | this.sourceBuffer && | 424 | this.sourceBuffer && |
423 | 425 | ||
424 | // 4) the active media playlist is available | 426 | // 4) the active media playlist is available |
425 | media) { | 427 | media && |
428 | |||
429 | // 5) the video element or flash player is in a readyState of | ||
430 | // at least HAVE_FUTURE_DATA | ||
431 | this.tech_.readyState >= 3) { | ||
426 | 432 | ||
427 | // seek to the latest media position for live videos | 433 | // seek to the latest media position for live videos |
428 | seekable = this.seekable(); | 434 | seekable = this.seekable(); |
... | @@ -1138,7 +1144,6 @@ videojs.HlsHandler.prototype.drainBuffer = function() { | ... | @@ -1138,7 +1144,6 @@ videojs.HlsHandler.prototype.drainBuffer = function() { |
1138 | segment = playlist.segments[mediaIndex]; | 1144 | segment = playlist.segments[mediaIndex]; |
1139 | 1145 | ||
1140 | if (segment.key && !bytes) { | 1146 | if (segment.key && !bytes) { |
1141 | |||
1142 | // this is an encrypted segment | 1147 | // this is an encrypted segment |
1143 | // if the key download failed, we want to skip this segment | 1148 | // if the key download failed, we want to skip this segment |
1144 | // but if the key hasn't downloaded yet, we want to try again later | 1149 | // but if the key hasn't downloaded yet, we want to try again later | ... | ... |
-
Please register or sign in to post a comment