Skip to content

Commit

Permalink
fix: retries
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Mar 1, 2024
1 parent 72e77c5 commit a827009
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
41 changes: 9 additions & 32 deletions src/TizenVideo/TizenVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ function TizenVideo(options) {
oncurrentplaytime: function() {
onPropChanged('time');
},
onerror: function() {
onVideoError();
},
onsubtitlechange: function(duration, text) {
renderSubtitle(duration, text);
},
Expand Down Expand Up @@ -357,18 +354,6 @@ function TizenVideo(options) {
}
}
}
function onVideoError() {
if (destroyed) {
return;
}

var error;
error = ERROR.UNKNOWN_ERROR;
onError(Object.assign({}, error, {
critical: true,
error: error
}));
}
function onError(error) {
events.emit('error', error);
if (error.critical) {
Expand Down Expand Up @@ -601,7 +586,6 @@ function TizenVideo(options) {
window.webapis.avplay.setDisplayMethod('PLAYER_DISPLAY_MODE_LETTER_BOX');
window.webapis.avplay.seekTo(commandArgs.time !== null && isFinite(commandArgs.time) ? parseInt(commandArgs.time, 10) : 0);
window.webapis.avplay.prepareAsync(function() {
if (!stream) return;
onPropChanged('duration');
window.webapis.avplay.play();

Expand All @@ -615,25 +599,18 @@ function TizenVideo(options) {
onPropChanged('selectedSubtitlesTrackId');
onPropChanged('audioTracks');
onPropChanged('selectedAudioTrackId');
}, function() {
// retries are necessary because there is a
// 30s timeout that cannot be configured
if (stream && retries <= maxRetries) {
}, function(error) {
if (retries < maxRetries) {
retries++;
try {
window.webapis.avplay.stop();
} catch(e) {}
setTimeout(function() {
command('load', commandArgs);
}, 0);
return;
command('load', commandArgs);
} else {
onError(Object.assign({}, ERROR.STREAM_FAILED_TO_LOAD, {
critical: true,
stream: commandArgs ? commandArgs.stream : null,
error: error,
}));
}
onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, {
critical: true,
stream: commandArgs ? commandArgs.stream : null
}));
});

} else {
onError(Object.assign({}, ERROR.UNSUPPORTED_STREAM, {
critical: true,
Expand Down
4 changes: 4 additions & 0 deletions src/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ var ERROR = {
UNSUPPORTED_STREAM: {
code: 2,
message: 'Stream is not supported'
},
STREAM_FAILED_TO_LOAD: {
code: 3,
message: 'Stream failed to load'
}
};

Expand Down

0 comments on commit a827009

Please sign in to comment.