21c692d7 by Steve Heffernan

Merge branch 'hotfix/stream-ended' of https://github.com/videojs/videojs-contrib…

…-hls into reorg-w-114

close #114 closes #115

Conflicts:
	src/videojs-hls.js
2 parents b22f4c3f 99abd78b
...@@ -158,6 +158,19 @@ videojs.Hls.prototype.handleSourceOpen = function() { ...@@ -158,6 +158,19 @@ videojs.Hls.prototype.handleSourceOpen = function() {
158 }); 158 });
159 }; 159 };
160 160
161 /**
162 * Reset the mediaIndex if play() is called after the video has
163 * ended.
164 */
165 videojs.Hls.prototype.play = function() {
166 if (this.ended()) {
167 this.mediaIndex = 0;
168 }
169
170 // delegate back to the Flash implementation
171 return videojs.Flash.prototype.play.apply(this, arguments);
172 };
173
161 videojs.Hls.prototype.duration = function() { 174 videojs.Hls.prototype.duration = function() {
162 var playlists = this.playlists; 175 var playlists = this.playlists;
163 if (playlists) { 176 if (playlists) {
...@@ -458,7 +471,9 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -458,7 +471,9 @@ videojs.Hls.prototype.drainBuffer = function(event) {
458 // we're done processing this segment 471 // we're done processing this segment
459 segmentBuffer.shift(); 472 segmentBuffer.shift();
460 473
461 if (mediaIndex === playlist.segments.length) { 474 // transition the sourcebuffer to the ended state if we've hit the end of
475 // the playlist
476 if (mediaIndex + 1 === playlist.segments.length) {
462 this.mediaSource.endOfStream(); 477 this.mediaSource.endOfStream();
463 } 478 }
464 }; 479 };
......