From 9501b5a98d22f47c7d6a0eefa1cd145965922c04 Mon Sep 17 00:00:00 2001 From: Felipe Leon Date: Wed, 21 Feb 2024 12:17:13 -0300 Subject: [PATCH] add workaround for wrong bit rates partial solve #207 We need to comeback and improve or remove this in the future --- app/specific/OSInterface.js | 21 ++++++++++++++++++++- app/specific/Play.js | 20 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/specific/OSInterface.js b/app/specific/OSInterface.js index 19672f98f..32dbfddae 100644 --- a/app/specific/OSInterface.js +++ b/app/specific/OSInterface.js @@ -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); } @@ -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); } @@ -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) { @@ -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)); } @@ -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); } @@ -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, diff --git a/app/specific/Play.js b/app/specific/Play.js index 6544604b7..ecfb90af7 100644 --- a/app/specific/Play.js +++ b/app/specific/Play.js @@ -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 = {}, @@ -972,7 +981,8 @@ 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 { @@ -980,13 +990,19 @@ function Play_extractQualities(input) { 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; }