Skip to content

Commit

Permalink
demo page: enable media error recovery
Browse files Browse the repository at this point in the history
recover max one error every 3s
  • Loading branch information
mangui committed Dec 7, 2015
1 parent 72275d0 commit e48e22a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ <h4> Stats Display </h4>
$('#metricsButtonWindow').toggle(windowSliding);
$('#metricsButtonFixed').toggle(!windowSliding);
$('#enableStream').click(function() { enableStreaming = this.checked; loadStream($('#streamURL').val());});
$('#autoRecoverError').prop( "checked", false );
$('#autoRecoverError').prop( "checked", true );
$('#autoRecoverError').click(function() { autoRecoverError = this.checked; });
});

'use strict';
var hls,events, stats, enableStreaming = true, autoRecoverError = false;
var hls,events, stats, enableStreaming = true, autoRecoverError = true;
var video = $('#video')[0];
video.volume = 0.05;

Expand Down Expand Up @@ -241,6 +241,7 @@ <h4> Stats Display </h4>

$("#HlsStatus").text('loading ' + url);
events = { url : url, t0 : performance.now(), load : [], buffer : [], video : [], level : [], bitrate : []};
recoverDecodingErrorDate = null;
hls = new Hls({debug:true});
$("#HlsStatus").text('loading manifest and attaching video element...');
hls.loadSource(url);
Expand Down Expand Up @@ -460,8 +461,14 @@ <h4> Stats Display </h4>
switch(data.type) {
case Hls.ErrorTypes.MEDIA_ERROR:
if(autoRecoverError) {
$("#HlsStatus").append(",try to recover media Error ...");
hls.recoverMediaError();
var now = performance.now();
if(!recoverDecodingErrorDate || (now - recoverDecodingErrorDate) > 3000) {
recoverDecodingErrorDate = performance.now();
$("#HlsStatus").append(",try to recover media Error ...");
hls.recoverMediaError();
} else {
$("#HlsStatus").append(",cannot recover, last media error recovery failed ...");
}
}
break;
case Hls.ErrorTypes.NETWORK_ERROR:
Expand Down Expand Up @@ -567,8 +574,14 @@ <h4> Stats Display </h4>
case mediaError.MEDIA_ERR_DECODE:
errorTxt = "The video playback was aborted due to a corruption problem or because the video used features your browser did not support";
if(autoRecoverError) {
errorTxt+=",try to recover video Error";
hls.recoverMediaError();
var now = performance.now();
if(!recoverDecodingErrorDate || (now - recoverDecodingErrorDate) > 3000) {
recoverDecodingErrorDate = performance.now();
$("#HlsStatus").append(",try to recover media Error ...");
hls.recoverMediaError();
} else {
$("#HlsStatus").append(",cannot recover, last media error recovery failed ...");
}
}
break;
case mediaError.MEDIA_ERR_NETWORK:
Expand Down

0 comments on commit e48e22a

Please sign in to comment.