Merge pull request #1099 from movie-web/feature/default-audio-language

Select default audio language based on setting
This commit is contained in:
Jorrin 2024-04-10 18:20:15 +02:00 committed by GitHub
commit b6c894a87a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import {
} from "@/components/player/display/displayInterface";
import { handleBuffered } from "@/components/player/utils/handleBuffered";
import { getMediaErrorDetails } from "@/components/player/utils/mediaErrorDetails";
import { useLanguageStore } from "@/stores/language";
import {
LoadableSource,
SourceQuality,
@ -83,7 +84,13 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
function reportAudioTracks() {
if (!hls) return;
const currentTrack = hls.audioTracks?.[hls.audioTrack ?? 0];
const currentLanguage = useLanguageStore.getState().language;
const audioTracks = hls.audioTracks;
const languageTrack = audioTracks.find((v) => v.lang === currentLanguage);
if (languageTrack) {
hls.audioTrack = audioTracks.indexOf(languageTrack);
}
const currentTrack = audioTracks?.[hls.audioTrack ?? 0];
if (!currentTrack) return;
emit("changedaudiotrack", {
id: currentTrack.id.toString(),

View File

@ -169,6 +169,8 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
s.captionList = captions;
s.interface.error = undefined;
s.status = playerStatus.PLAYING;
s.audioTracks = [];
s.currentAudioTrack = null;
});
const store = get();
store.redisplaySource(startAt);