Browse Source

Merge pull request #1070 from movie-web/fix/hls-audio-not-proxied

Route HLS audio tracks through extension
pull/1071/head
William Oldham 1 year ago committed by GitHub
parent
commit
1e0b86badf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      src/backend/extension/messaging.ts
  2. 15
      src/components/player/display/base.ts

1
src/backend/extension/messaging.ts

@ -9,6 +9,7 @@ import { ExtensionMakeRequestResponse } from "@/backend/extension/plasmo"; @@ -9,6 +9,7 @@ import { ExtensionMakeRequestResponse } from "@/backend/extension/plasmo";
export const RULE_IDS = {
PREPARE_STREAM: 1,
SET_DOMAINS_HLS: 2,
SET_DOMAINS_HLS_AUDIO: 3,
};
// for some reason, about 500 ms is needed after

15
src/components/player/display/base.ts

@ -191,6 +191,21 @@ export function makeVideoElementDisplayInterface(): DisplayInterface { @@ -191,6 +191,21 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
},
});
});
hls.on(Hls.Events.AUDIO_TRACK_LOADED, async (_, data) => {
const chunkUrlsDomains = data.details.fragments.map(
(v) => new URL(v.url).hostname,
);
const chunkUrls = [...new Set(chunkUrlsDomains)];
await setDomainRule({
ruleId: RULE_IDS.SET_DOMAINS_HLS_AUDIO,
targetDomains: chunkUrls,
requestHeaders: {
...src.preferredHeaders,
...src.headers,
},
});
});
}
});
hls.on(Hls.Events.LEVEL_SWITCHED, () => {

Loading…
Cancel
Save