Skip to content

Commit

Permalink
[Test] Retry Until Source Info Retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
jaruba committed May 30, 2024
1 parent bf90df0 commit 220f94e
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions src/WebOsVideo/WebOsVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ function WebOsVideo(options) {

var isLoaded = null;

var videoLoaded = false;

var knownMediaId = false;

var gotSourceInfo = false;

var subSize = 75;

var disabledSubs = true;
Expand Down Expand Up @@ -259,8 +259,8 @@ function WebOsVideo(options) {
// eslint-disable-next-line no-console
console.log('subscribe result is', JSON.stringify(result));

if ((result || {}).sourceInfo && !answered) {
answered = true;
if ((result || {}).sourceInfo && !gotSourceInfo) {
gotSourceInfo = true;

if (((result.sourceInfo || {}).programInfo || [])[0]) {
var info = result.sourceInfo.programInfo[0];
Expand All @@ -270,7 +270,10 @@ function WebOsVideo(options) {
setTracks(info);
}

unsubscribe(cb);
if (!answered) {
answered = true;
unsubscribe(cb);
}

return;
}
Expand Down Expand Up @@ -308,7 +311,7 @@ function WebOsVideo(options) {
console.log('luna subscribe error message');
// eslint-disable-next-line no-console
console.log((err || {}).errorText);
if ((err || {}).mediaId === '<invalid mediaId>' && subscribeRetries < 5) {
if (((err || {}).mediaId === '<invalid mediaId>' || !gotSourceInfo) && subscribeRetries < 5) {
// eslint-disable-next-line no-console
console.log('waiting 0.2s and retrying to subscribe, count', subscribeRetries);
subscribed = false;
Expand Down Expand Up @@ -1013,16 +1016,6 @@ function WebOsVideo(options) {

subscribe(cb);

setTimeout(function() {
try {
videoElement.load();
videoLoaded = true;
} catch(e) {
console.log('can\'t load video');
console.error(e);
}
}, 0);

return;
}
count++;
Expand All @@ -1042,14 +1035,11 @@ function WebOsVideo(options) {
// not needed?
// videoElement.src = stream.url;

if (!videoLoaded) {
try {
videoElement.load();
} catch(e) {
// console.log('can\'t load video');
// console.error(e);
}
videoLoaded = true;
try {
videoElement.load();
} catch(e) {
// console.log('can\'t load video');
// console.error(e);
}

try {
Expand Down

0 comments on commit 220f94e

Please sign in to comment.