Allow manually forcing HLS.js on

This commit is contained in:
Jade Macho 2024-03-01 21:20:24 +01:00
parent e383aa4738
commit 0cce72b24b
Signed by: 0x0ade
GPG Key ID: E1960710FE4FBEEF
2 changed files with 37 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import Jadefin from "../../Jadefin.js";
import JadefinMod from "../../JadefinMod.js"; import JadefinMod from "../../JadefinMod.js";
import JadefinModules from "../../JadefinModules.js"; import JadefinModules from "../../JadefinModules.js";
// https://github.com/jellyfin/jellyfin-android/issues/1031 // Mainly spawned from https://github.com/jellyfin/jellyfin-android/issues/1031
export default JadefinIntegrity("PatchAndroidHLSJS", import.meta.url, () => new (class PatchAndroidHLSJS extends JadefinMod { export default JadefinIntegrity("PatchAndroidHLSJS", import.meta.url, () => new (class PatchAndroidHLSJS extends JadefinMod {
constructor() { constructor() {
super(); super();
@ -14,6 +14,14 @@ export default JadefinIntegrity("PatchAndroidHLSJS", import.meta.url, () => new
this.enableHlsJsPlayer = this.enableHlsJsPlayer.bind(this); this.enableHlsJsPlayer = this.enableHlsJsPlayer.bind(this);
} }
get isEnabled() {
return this.storage.get("isEnabled", false);
}
set isEnabled(value) {
this.storage.set("isEnabled", value);
}
async init(name, url) { async init(name, url) {
await super.init(name, url); await super.init(name, url);
@ -21,9 +29,36 @@ export default JadefinIntegrity("PatchAndroidHLSJS", import.meta.url, () => new
this._enableHlsJsPlayer = htmlMediaHelper.rR.bind(htmlMediaHelper); this._enableHlsJsPlayer = htmlMediaHelper.rR.bind(htmlMediaHelper);
Object.defineProperty(htmlMediaHelper, "rR", { get: () => this.enableHlsJsPlayer }); Object.defineProperty(htmlMediaHelper, "rR", { get: () => this.enableHlsJsPlayer });
const ExtrasMenu = /** @type {import("../ExtrasMenu.js").default} */ (Jadefin.getMod("ExtrasMenu"));
ExtrasMenu.items.push({
name: "Enable HLS.js",
secondaryText: "Sometimes helps with playback in some browsers",
icon: "auto_fix_normal",
in: ExtrasMenu.IN_CUSTOM,
inCustom: (current, item) => {
if (!this.isEnabled) {
item.name = "Enable HLS.js";
item.icon = "auto_fix_normal";
} else {
item.name = "Disable HLS.js";
item.icon = "auto_fix_off";
}
return true;
},
cb: () => {
this.isEnabled = !this.isEnabled;
}
});
} }
enableHlsJsPlayer(runTimeTicks, mediaType) { enableHlsJsPlayer(runTimeTicks, mediaType) {
if (this.isEnabled) {
return true;
}
// https://github.com/jellyfin/jellyfin-web/commit/baf1b55a0cb83d4cb63a18968fc93493ce785498 // https://github.com/jellyfin/jellyfin-web/commit/baf1b55a0cb83d4cb63a18968fc93493ce785498
if (JadefinModules.browser.android && mediaType === "Video") { if (JadefinModules.browser.android && mediaType === "Video") {
mediaType = "Audio"; mediaType = "Audio";

View File

@ -8,5 +8,5 @@
"Transcript.js", "Transcript.js",
"jade/Shortcuts.js", "jade/Shortcuts.js",
"jade/PatchAndroidHLSJS.js" "jade/PatchForceHLSJS.js"
] ]