mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Merge pull request #1070 from movie-web/fix/hls-audio-not-proxied
Route HLS audio tracks through extension
This commit is contained in:
commit
1e0b86badf
2 changed files with 16 additions and 0 deletions
|
@ -9,6 +9,7 @@ import { ExtensionMakeRequestResponse } from "@/backend/extension/plasmo";
|
||||||
export const RULE_IDS = {
|
export const RULE_IDS = {
|
||||||
PREPARE_STREAM: 1,
|
PREPARE_STREAM: 1,
|
||||||
SET_DOMAINS_HLS: 2,
|
SET_DOMAINS_HLS: 2,
|
||||||
|
SET_DOMAINS_HLS_AUDIO: 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
// for some reason, about 500 ms is needed after
|
// for some reason, about 500 ms is needed after
|
||||||
|
|
|
@ -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, () => {
|
hls.on(Hls.Events.LEVEL_SWITCHED, () => {
|
||||||
|
|
Loading…
Reference in a new issue