diff --git a/src/components/player/base/BackLink.tsx b/src/components/player/base/BackLink.tsx index a965751f..251a673c 100644 --- a/src/components/player/base/BackLink.tsx +++ b/src/components/player/base/BackLink.tsx @@ -1,23 +1,21 @@ import { useTranslation } from "react-i18next"; -import { useNavigate } from "react-router-dom"; +import { Link } from "react-router-dom"; import { Icon, Icons } from "@/components/Icon"; export function BackLink(props: { url: string }) { const { t } = useTranslation(); - const navigate = useNavigate(); return (
- +
); } diff --git a/src/components/player/display/base.ts b/src/components/player/display/base.ts index b1eb616f..ebaa12da 100644 --- a/src/components/player/display/base.ts +++ b/src/components/player/display/base.ts @@ -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(), diff --git a/src/components/player/internals/KeyboardEvents.tsx b/src/components/player/internals/KeyboardEvents.tsx index 3a833e76..af2724c9 100644 --- a/src/components/player/internals/KeyboardEvents.tsx +++ b/src/components/player/internals/KeyboardEvents.tsx @@ -71,9 +71,10 @@ export function KeyboardEvents() { return; const k = evt.key; + const keyL = evt.key.toLowerCase(); // Volume - if (["ArrowUp", "ArrowDown", "m"].includes(k)) { + if (["ArrowUp", "ArrowDown", "m", "M"].includes(k)) { dataRef.current.setShowVolume(true); if (volumeDebounce.current) clearTimeout(volumeDebounce.current); @@ -89,7 +90,7 @@ export function KeyboardEvents() { dataRef.current.setVolume( (dataRef.current.mediaPlaying?.volume || 0) - 0.15, ); - if (k === "m") dataRef.current.toggleMute(); + if (keyL === "m") dataRef.current.toggleMute(); // Video playback speed if (k === ">" || k === "<") { @@ -106,9 +107,9 @@ export function KeyboardEvents() { dataRef.current.display?.setTime(dataRef.current.time + 5); if (k === "ArrowLeft") dataRef.current.display?.setTime(dataRef.current.time - 5); - if (k === "j") + if (keyL === "j") dataRef.current.display?.setTime(dataRef.current.time - 10); - if (k === "l") + if (keyL === "l") dataRef.current.display?.setTime(dataRef.current.time + 10); if (k === "." && dataRef.current.mediaPlaying?.isPaused) dataRef.current.display?.setTime(dataRef.current.time + 1); @@ -116,18 +117,18 @@ export function KeyboardEvents() { dataRef.current.display?.setTime(dataRef.current.time - 1); // Utils - if (k === "f") dataRef.current.display?.toggleFullscreen(); - if (k === " ") + if (keyL === "f") dataRef.current.display?.toggleFullscreen(); + if (k === " " || keyL === "k") dataRef.current.display?.[ dataRef.current.mediaPlaying.isPaused ? "play" : "pause" ](); if (k === "Escape") dataRef.current.router.close(); // captions - if (k === "c") dataRef.current.toggleLastUsed().catch(() => {}); // ignore errors + if (keyL === "c") dataRef.current.toggleLastUsed().catch(() => {}); // ignore errors // Do a barrell roll! - if (k === "r") { + if (keyL === "r") { if (dataRef.current.isRolling || evt.ctrlKey || evt.metaKey) return; dataRef.current.setIsRolling(true); diff --git a/src/stores/player/slices/source.ts b/src/stores/player/slices/source.ts index eb2ce9e1..5cbfc6db 100644 --- a/src/stores/player/slices/source.ts +++ b/src/stores/player/slices/source.ts @@ -169,6 +169,8 @@ export const createSourceSlice: MakeSlice = (set, get) => ({ s.captionList = captions; s.interface.error = undefined; s.status = playerStatus.PLAYING; + s.audioTracks = []; + s.currentAudioTrack = null; }); const store = get(); store.redisplaySource(startAt);