Skip to content

Commit

Permalink
add workaround for wrong bit rates
Browse files Browse the repository at this point in the history
partial solve #207

We need to comeback and improve or remove this in the future
  • Loading branch information
fgl27 committed Feb 21, 2024
1 parent 9d6df8d commit 9501b5a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
21 changes: 20 additions & 1 deletion app/specific/OSInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ function OSInterface_RestartPlayer(who_called, ResumePosition, player) {
//Android specific: false in the OS has multi player supports Samsung TV for example don't have
//Sets mediaSources and start the player
function OSInterface_StartAuto(uri, mainPlaylistString, who_called, ResumePosition, player) {
if (who_called === 1) {
mainPlaylistString = Play_FixQualities(mainPlaylistString);
}

Android.StartAuto(uri, mainPlaylistString, who_called, ResumePosition, player);
}

Expand All @@ -335,6 +339,10 @@ function OSInterface_StartAuto(uri, mainPlaylistString, who_called, ResumePositi
//Android specific: false in the OS has multi player supports Samsung TV for example don't have
//Sets mediaSources and start the player
function OSInterface_ReuseFeedPlayer(uri, mainPlaylistString, who_called, ResumePosition, player) {
if (who_called === 1) {
mainPlaylistString = Play_FixQualities(mainPlaylistString);
}

Android.ReuseFeedPlayer(uri, mainPlaylistString, who_called, ResumePosition, player);
}

Expand Down Expand Up @@ -696,13 +704,14 @@ function OSInterface_DisableMultiStream() {
//Android specific: true
//Start MultiStream at position
function OSInterface_StartMultiStream(position, uri, mainPlaylistString, Restart) {
mainPlaylistString = Play_FixQualities(mainPlaylistString);

Android.StartMultiStream(position, uri, mainPlaylistString, Boolean(Restart));
}

//public void EnableMultiStream(boolean MainBig, int offset)
//MainBig = MainBig mode if true the main player is bigger
//offset = is the player position offset on the screen, one can click left right to change with will be the main player, the offset determines the position of it player
//mainPlaylistString = main Playlist String
//Android specific: true
//Start MultiStream and allows to change its mode
function OSInterface_EnableMultiStream(MainBig, offset) {
Expand Down Expand Up @@ -760,6 +769,10 @@ function OSInterface_SetPreviewOthersAudio(volume) {
//Android specific: true
//Start MultiStream at position
function OSInterface_StartFeedPlayer(uri, mainPlaylistString, position, resumePosition, isVod) {
if (!isVod) {
mainPlaylistString = Play_FixQualities(mainPlaylistString);
}

Android.StartFeedPlayer(uri, mainPlaylistString, position, resumePosition, Boolean(isVod));
}

Expand All @@ -769,6 +782,8 @@ function OSInterface_StartFeedPlayer(uri, mainPlaylistString, position, resumePo
//Android specific: true
//Start MultiStream at position
function OSInterface_StartSidePanelPlayer(uri, mainPlaylistString) {
mainPlaylistString = Play_FixQualities(mainPlaylistString);

Android.StartSidePanelPlayer(uri, mainPlaylistString);
}

Expand Down Expand Up @@ -800,6 +815,10 @@ function OSInterface_SetPlayerViewSidePanel(bottom, right, left, web_height) {
//Android specific: true
//Start MultiStream at position
function OSInterface_StartScreensPlayer(uri, mainPlaylistString, ResumePosition, bottom, right, left, web_height, who_called) {
if (who_called === 1) {
mainPlaylistString = Play_FixQualities(mainPlaylistString);
}

Android.StartScreensPlayer(
uri,
mainPlaylistString,
Expand Down
20 changes: 18 additions & 2 deletions app/specific/Play.js
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,15 @@ function Play_SetExternalQualities(array, startPos, name) {
Main_Log('Play_SetExternalQualities ' + JSON.stringify(array) + ' name ' + name);
}

function Play_FixQualities(input) {
var qualities = Play_extractQualities(input);

if (qualities[0].truebitrate) {
input = input.replace(qualities[0].bitrate, qualities[0].truebitrate);
}
return input;
}

function Play_extractQualities(input) {
var result = [],
addedresolution = {},
Expand All @@ -972,21 +981,28 @@ function Play_extractQualities(input) {

result.push({
id: marray2[1] + Play_extractBand(marray2[2]) + Play_extractCodec(marray2[3]),
url: marray2[4]
url: marray2[4],
bitrate: parseInt(marray2[2])
});
addedresolution[marray2[1].split(' | ')[0]] = 1;
} else {
//Prevent duplicated resolution 720p60 source and 720p60
if (!addedresolution[marray2[1]]) {
result.push({
id: marray2[1] + Play_extractBand(marray2[2]) + Play_extractCodec(marray2[3]),
url: marray2[4]
url: marray2[4],
bitrate: parseInt(marray2[2])
});
addedresolution[marray2[1]] = 1;
}
}
}
}

if (result[0].bitrate < result[1].bitrate) {
result[0].truebitrate = result[0].bitrate + result[1].bitrate;
}

return result;
}

Expand Down

0 comments on commit 9501b5a

Please sign in to comment.