d57b213a by jrivera

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.
1 parent 41259aaf
......@@ -165,6 +165,8 @@ videojs.HlsHandler.prototype.src = function(src) {
}
this.playlists = new videojs.Hls.PlaylistLoader(this.source_.src, this.options_.withCredentials);
this.tech_.on('canplay', this.setupFirstPlay.bind(this));
this.playlists.on('loadedmetadata', function() {
oldMediaPlaylist = this.playlists.media();
......@@ -422,7 +424,11 @@ videojs.HlsHandler.prototype.setupFirstPlay = function() {
this.sourceBuffer &&
// 4) the active media playlist is available
media) {
media &&
// 5) the video element or flash player is in a readyState of
// at least HAVE_FUTURE_DATA
this.tech_.readyState >= 3) {
// seek to the latest media position for live videos
seekable = this.seekable();
......@@ -1138,7 +1144,6 @@ videojs.HlsHandler.prototype.drainBuffer = function() {
segment = playlist.segments[mediaIndex];
if (segment.key && !bytes) {
// this is an encrypted segment
// if the key download failed, we want to skip this segment
// but if the key hasn't downloaded yet, we want to try again later
......