Skip to content

Commit

Permalink
Improve Play_isIdleOrPlaying
Browse files Browse the repository at this point in the history
related to #277
  • Loading branch information
fgl27 committed Nov 30, 2023
1 parent 4415ba9 commit 4b762ee
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions app/specific/Play.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,11 +1308,15 @@ function Play_PlayerCheck() {
Play_qualityPlaying.indexOf('Auto') === -1
)
Play_qualityIndex++;
else if (!Play_PlayerCheckQualityChanged && Play_PlayerCheckRun) Play_PlayerCheckCounter++;
else if (!Play_PlayerCheckQualityChanged && Play_PlayerCheckRun) {
Play_PlayerCheckCounter++;
}

if (!navigator.onLine) Play_EndStart(false, 1);
else if (Play_PlayerCheckCounter > 1) Play_CheckConnection(Play_PlayerCheckCounter, 1, Play_DropOneQuality);
else {
if (!navigator.onLine) {
Play_EndStart(false, 1);
} else if (Play_PlayerCheckCounter > 1) {
Play_CheckConnection(Play_PlayerCheckCounter, 1, Play_DropOneQuality);
} else {
Play_qualityDisplay(Play_getQualitiesCount, Play_qualityIndex, Play_SetHtmlQuality);
Play_qualityChanged();
Play_PlayerCheckRun = true;
Expand All @@ -1330,8 +1334,21 @@ function Play_PlayerCheck() {
// So we use PlayerCheck to avaluate if we are staled fro too long or not and drop the quality
function Play_isIdleOrPlaying() {
if (Main_IsNotBrowser) {
var state = Play_avplay.getState();
return !Play_isEndDialogVisible() && (state === 'IDLE' || state === 'PLAYING');
var state;
try {
state = Play_avplay.getState();
} catch (error) {
console.error(error);
//on error reset all player status and restart the player
state = 'ERROR';
Play_PlayerCheckRun = false;
PlayVod_PlayerCheckRun = false;
PlayClip_PlayerCheckRun = false;
Play_PlayerCheckCount = Play_PlayerCheckTimer;
PlayVod_PlayerCheckCount = Play_PlayerCheckTimer;
PlayClip_PlayerCheckCount = Play_PlayerCheckTimer;
}
return !Play_isEndDialogVisible() && (state === 'IDLE' || state === 'PLAYING' || state === 'ERROR');
}
return false;
}
Expand Down

0 comments on commit 4b762ee

Please sign in to comment.