1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

Merge branch 'dev' into fix/next-episode

This commit is contained in:
William Oldham 2024-04-14 21:17:41 +01:00 committed by GitHub
commit 85337018b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 15 deletions

View file

@ -1,23 +1,21 @@
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { Link } from "react-router-dom";
import { Icon, Icons } from "@/components/Icon"; import { Icon, Icons } from "@/components/Icon";
export function BackLink(props: { url: string }) { export function BackLink(props: { url: string }) {
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate();
return ( return (
<div className="flex items-center"> <div className="flex items-center">
<button <Link
type="button" to={props.url}
onClick={() => navigate(props.url)}
className="py-1 -my-1 px-2 -mx-2 tabbable rounded-lg flex items-center cursor-pointer text-type-secondary hover:text-white transition-colors duration-200 font-medium" className="py-1 -my-1 px-2 -mx-2 tabbable rounded-lg flex items-center cursor-pointer text-type-secondary hover:text-white transition-colors duration-200 font-medium"
> >
<Icon className="mr-2" icon={Icons.ARROW_LEFT} /> <Icon className="mr-2" icon={Icons.ARROW_LEFT} />
<span className="md:hidden">{t("player.back.short")}</span> <span className="md:hidden">{t("player.back.short")}</span>
<span className="hidden md:block">{t("player.back.default")}</span> <span className="hidden md:block">{t("player.back.default")}</span>
</button> </Link>
</div> </div>
); );
} }

View file

@ -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(),

View file

@ -71,9 +71,10 @@ export function KeyboardEvents() {
return; return;
const k = evt.key; const k = evt.key;
const keyL = evt.key.toLowerCase();
// Volume // Volume
if (["ArrowUp", "ArrowDown", "m"].includes(k)) { if (["ArrowUp", "ArrowDown", "m", "M"].includes(k)) {
dataRef.current.setShowVolume(true); dataRef.current.setShowVolume(true);
if (volumeDebounce.current) clearTimeout(volumeDebounce.current); if (volumeDebounce.current) clearTimeout(volumeDebounce.current);
@ -89,7 +90,7 @@ export function KeyboardEvents() {
dataRef.current.setVolume( dataRef.current.setVolume(
(dataRef.current.mediaPlaying?.volume || 0) - 0.15, (dataRef.current.mediaPlaying?.volume || 0) - 0.15,
); );
if (k === "m") dataRef.current.toggleMute(); if (keyL === "m") dataRef.current.toggleMute();
// Video playback speed // Video playback speed
if (k === ">" || k === "<") { if (k === ">" || k === "<") {
@ -106,9 +107,9 @@ export function KeyboardEvents() {
dataRef.current.display?.setTime(dataRef.current.time + 5); dataRef.current.display?.setTime(dataRef.current.time + 5);
if (k === "ArrowLeft") if (k === "ArrowLeft")
dataRef.current.display?.setTime(dataRef.current.time - 5); dataRef.current.display?.setTime(dataRef.current.time - 5);
if (k === "j") if (keyL === "j")
dataRef.current.display?.setTime(dataRef.current.time - 10); dataRef.current.display?.setTime(dataRef.current.time - 10);
if (k === "l") if (keyL === "l")
dataRef.current.display?.setTime(dataRef.current.time + 10); dataRef.current.display?.setTime(dataRef.current.time + 10);
if (k === "." && dataRef.current.mediaPlaying?.isPaused) if (k === "." && dataRef.current.mediaPlaying?.isPaused)
dataRef.current.display?.setTime(dataRef.current.time + 1); dataRef.current.display?.setTime(dataRef.current.time + 1);
@ -116,18 +117,18 @@ export function KeyboardEvents() {
dataRef.current.display?.setTime(dataRef.current.time - 1); dataRef.current.display?.setTime(dataRef.current.time - 1);
// Utils // Utils
if (k === "f") dataRef.current.display?.toggleFullscreen(); if (keyL === "f") dataRef.current.display?.toggleFullscreen();
if (k === " ") if (k === " " || keyL === "k")
dataRef.current.display?.[ dataRef.current.display?.[
dataRef.current.mediaPlaying.isPaused ? "play" : "pause" dataRef.current.mediaPlaying.isPaused ? "play" : "pause"
](); ]();
if (k === "Escape") dataRef.current.router.close(); if (k === "Escape") dataRef.current.router.close();
// captions // captions
if (k === "c") dataRef.current.toggleLastUsed().catch(() => {}); // ignore errors if (keyL === "c") dataRef.current.toggleLastUsed().catch(() => {}); // ignore errors
// Do a barrell roll! // Do a barrell roll!
if (k === "r") { if (keyL === "r") {
if (dataRef.current.isRolling || evt.ctrlKey || evt.metaKey) return; if (dataRef.current.isRolling || evt.ctrlKey || evt.metaKey) return;
dataRef.current.setIsRolling(true); dataRef.current.setIsRolling(true);

View file

@ -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);