mirror of
https://github.com/p-stream/p-stream.git
synced 2026-01-11 20:10:32 +00:00
fix native captions being initialized wrong for mp4
This commit is contained in:
parent
cb5a363b6a
commit
1c9f02ba8e
1 changed files with 9 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import subsrt from "subsrt-ts";
|
|||
import { downloadCaption, downloadWebVTT } from "@/backend/helpers/subs";
|
||||
import { Caption } from "@/stores/player/slices/source";
|
||||
import { usePlayerStore } from "@/stores/player/store";
|
||||
import { usePreferencesStore } from "@/stores/preferences";
|
||||
import { useSubtitleStore } from "@/stores/subtitles";
|
||||
|
||||
import {
|
||||
|
|
@ -30,6 +31,9 @@ export function useCaptions() {
|
|||
(s) => s.display?.setSubtitlePreference,
|
||||
);
|
||||
const setCaptionAsTrack = usePlayerStore((s) => s.setCaptionAsTrack);
|
||||
const enableNativeSubtitles = usePreferencesStore(
|
||||
(s) => s.enableNativeSubtitles,
|
||||
);
|
||||
|
||||
const captions = useMemo(
|
||||
() =>
|
||||
|
|
@ -86,8 +90,11 @@ export function useCaptions() {
|
|||
setLanguage(caption.language);
|
||||
|
||||
// Use native tracks for MP4 streams instead of custom rendering
|
||||
if (source?.type === "file") {
|
||||
if (source?.type === "file" && enableNativeSubtitles) {
|
||||
setCaptionAsTrack(true);
|
||||
} else {
|
||||
// For HLS sources or when native subtitles are disabled, use custom rendering
|
||||
setCaptionAsTrack(false);
|
||||
}
|
||||
},
|
||||
[
|
||||
|
|
@ -100,6 +107,7 @@ export function useCaptions() {
|
|||
setSubtitlePreference,
|
||||
source,
|
||||
setCaptionAsTrack,
|
||||
enableNativeSubtitles,
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue