mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix srt selection when switching mode (#508)
This commit is contained in:
parent
aec23ae749
commit
27b0c753bb
@ -25,7 +25,7 @@ import { percent, px } from "yoshiki/native";
|
|||||||
import { Button } from "./button";
|
import { Button } from "./button";
|
||||||
import { imageBorderRadius } from "./constants";
|
import { imageBorderRadius } from "./constants";
|
||||||
import { P } from "./text";
|
import { P } from "./text";
|
||||||
import { ContrastArea, SwitchVariant } from "./themes";
|
import { SwitchVariant } from "./themes";
|
||||||
import { ts } from "./utils";
|
import { ts } from "./utils";
|
||||||
|
|
||||||
export type Snackbar = {
|
export type Snackbar = {
|
||||||
|
@ -177,7 +177,11 @@ export const Video = memo(function Video({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!subtitles) return;
|
if (!subtitles) return;
|
||||||
setSubtitle((subtitle) => {
|
setSubtitle((subtitle) => {
|
||||||
const subRet = subtitle ? subtitles.find((x) => x.language === subtitle.language) : null;
|
const subRet = subtitle
|
||||||
|
? subtitles.find(
|
||||||
|
(x) => x.language === subtitle.language && x.isForced === subtitle.isForced,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
if (subRet) return subRet;
|
if (subRet) return subRet;
|
||||||
if (!defaultSubLanguage) return null;
|
if (!defaultSubLanguage) return null;
|
||||||
if (defaultSubLanguage === "default") return subtitles.find((x) => x.isDefault) ?? null;
|
if (defaultSubLanguage === "default") return subtitles.find((x) => x.isDefault) ?? null;
|
||||||
|
@ -274,6 +274,7 @@ const useSubtitle = (
|
|||||||
) => {
|
) => {
|
||||||
const htmlTrack = useRef<HTMLTrackElement | null>();
|
const htmlTrack = useRef<HTMLTrackElement | null>();
|
||||||
const subOcto = useRef<Jassub | null>();
|
const subOcto = useRef<Jassub | null>();
|
||||||
|
const mode = useAtom(playModeAtom);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!player.current) return;
|
if (!player.current) return;
|
||||||
@ -334,7 +335,9 @@ const useSubtitle = (
|
|||||||
subOcto.current.setTrackByUrl(value.link);
|
subOcto.current.setTrackByUrl(value.link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [player, value, fonts]);
|
// also include mode because srt get's disabled when the mode change (no idea why)
|
||||||
|
mode;
|
||||||
|
}, [player.current, value, fonts, mode]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
if (subOcto.current) subOcto.current.destroy();
|
if (subOcto.current) subOcto.current.destroy();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user