e528f83b by Tom Johnson

Merge branch 'feature/basic-playback' of github.com:brightcove/videojs-contrib-h…

…ls into feature/basic-playback
2 parents 9d311e27 b713aa5b
......@@ -292,11 +292,10 @@ var
// always start playback with the default rendition
if (!player.hls.media) {
player.hls.media = player.hls.master.playlists[0];
if (parser.manifest.totalDuration) {
// update the duration
if (parser.manifest.totalDuration) {
player.duration(parser.manifest.totalDuration);
// Notify the flash layer
//player.el().querySelector('.vjs-tech').vjs_setProperty('duration',parser.manifest.totalDuration);
} else {
player.duration(totalDuration(parser.manifest));
}
......@@ -311,8 +310,9 @@ var
downloadPlaylist(resolveUrl(srcUrl, playlist.uri));
} else {
player.hls.media = playlist;
if (player.hls.media.totalDuration) {
// update the duration
if (player.hls.media.totalDuration) {
player.duration(player.hls.media.totalDuration);
} else {
player.duration(totalDuration(player.hls.media));
......@@ -370,28 +370,25 @@ var
segmentXhr.onreadystatechange = function() {
var playlist;
if (this.readyState === 4) {
if (this.status >= 400) {
if(player.hls.mediaIndex<player.hls.media.segments.length-1)
{
player.hls.mediaIndex++;
// wait until the request completes
if (this.readyState !== 4) {
return;
}
// the segment request is no longer outstanding
segmentXhr = null;
fillBuffer();
} else {
player.error = {
type: 'hls-missing-segment',
message: 'HLS Missing Segment at index ' + player.hls.mediaIndex,
// trigger an error if the request was not successful
if (this.status >= 400) {
player.hls.error = {
status: this.status,
message: 'HLS segment request error at URL: ' + segmentUri,
code: (this.status >= 500) ? 4 : 2
};
player.trigger('error');
}
return;
}
// the segment request is no longer outstanding
segmentXhr = null;
// stop processing if the request was aborted
if (!this.response) {
return;
......@@ -423,7 +420,6 @@ var
player.hls.mediaIndex++;
if (player.hls.mediaIndex === player.hls.media.segments.length) {
//TODO - Fix the endofstream //
mediaSource.endOfStream();
return;
}
......@@ -436,7 +432,6 @@ var
} else {
player.hls.media = playlist;
}
}
};
startTime = +new Date();
segmentXhr.send(null);
......
......@@ -603,8 +603,8 @@ test('segment 404 should trigger MEDIA_ERR_NETWORK', function () {
});
equal(true, errorTriggered, 'Missing Segment error event should trigger');
equal(2, player.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_NETWORK');
equal('hls-missing-segment', player.error.type, 'Player error type should inform user correctly');
ok(player.hls.error.message, 'an error message is available');
equal(2, player.hls.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_NETWORK');
});
test('segment 500 should trigger MEDIA_ERR_ABORTED', function () {
......@@ -634,8 +634,8 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () {
});
equal(true, errorTriggered, 'Missing Segment error event should trigger');
equal(4, player.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_ABORTED');
equal('hls-missing-segment', player.error.type, 'Player error type should inform user correctly');
ok(player.hls.error.message, 'an error message is available');
equal(4, player.hls.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_ABORTED');
});
module('segment controller', {
......