mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
Merge pull request #1099 from movie-web/feature/default-audio-language
Select default audio language based on setting
This commit is contained in:
commit
b6c894a87a
2 changed files with 10 additions and 1 deletions
|
@ -12,6 +12,7 @@ import {
|
||||||
} from "@/components/player/display/displayInterface";
|
} from "@/components/player/display/displayInterface";
|
||||||
import { handleBuffered } from "@/components/player/utils/handleBuffered";
|
import { handleBuffered } from "@/components/player/utils/handleBuffered";
|
||||||
import { getMediaErrorDetails } from "@/components/player/utils/mediaErrorDetails";
|
import { getMediaErrorDetails } from "@/components/player/utils/mediaErrorDetails";
|
||||||
|
import { useLanguageStore } from "@/stores/language";
|
||||||
import {
|
import {
|
||||||
LoadableSource,
|
LoadableSource,
|
||||||
SourceQuality,
|
SourceQuality,
|
||||||
|
@ -83,7 +84,13 @@ export function makeVideoElementDisplayInterface(): DisplayInterface {
|
||||||
|
|
||||||
function reportAudioTracks() {
|
function reportAudioTracks() {
|
||||||
if (!hls) return;
|
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;
|
if (!currentTrack) return;
|
||||||
emit("changedaudiotrack", {
|
emit("changedaudiotrack", {
|
||||||
id: currentTrack.id.toString(),
|
id: currentTrack.id.toString(),
|
||||||
|
|
|
@ -169,6 +169,8 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
|
||||||
s.captionList = captions;
|
s.captionList = captions;
|
||||||
s.interface.error = undefined;
|
s.interface.error = undefined;
|
||||||
s.status = playerStatus.PLAYING;
|
s.status = playerStatus.PLAYING;
|
||||||
|
s.audioTracks = [];
|
||||||
|
s.currentAudioTrack = null;
|
||||||
});
|
});
|
||||||
const store = get();
|
const store = get();
|
||||||
store.redisplaySource(startAt);
|
store.redisplaySource(startAt);
|
||||||
|
|
Loading…
Reference in a new issue