jadefin/mods/jade/PatchAndroidHLSJS.js
2024-03-01 21:01:22 +01:00

35 lines
1.2 KiB
JavaScript

//@ts-check
import JadefinIntegrity from '../../JadefinIntegrity.js';
import Jadefin from "../../Jadefin.js";
import JadefinMod from "../../JadefinMod.js";
import JadefinModules from "../../JadefinModules.js";
// https://github.com/jellyfin/jellyfin-android/issues/1031
export default JadefinIntegrity("PatchAndroidHLSJS", import.meta.url, () => new (class PatchAndroidHLSJS extends JadefinMod {
constructor() {
super();
this.enableHlsJsPlayer = this.enableHlsJsPlayer.bind(this);
}
async init(name, url) {
await super.init(name, url);
const htmlMediaHelper = this.htmlMediaPlayer = Jadefin.findWebpackRawLoad(e => (e.rR?.toString().indexOf("x-mpegURL") || -1) != -1)[0];
this._enableHlsJsPlayer = htmlMediaHelper.rR.bind(htmlMediaHelper);
Object.defineProperty(htmlMediaHelper, "rR", { get: () => this.enableHlsJsPlayer });
}
enableHlsJsPlayer(runTimeTicks, mediaType) {
// https://github.com/jellyfin/jellyfin-web/commit/baf1b55a0cb83d4cb63a18968fc93493ce785498
if (JadefinModules.browser.android && mediaType === "Video") {
mediaType = "Audio";
}
return this._enableHlsJsPlayer?.(runTimeTicks, mediaType);
}
})());