mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -04:00
Fix segments list having a greater length than capacity (#370)
This commit is contained in:
commit
266caa3f02
@ -62,6 +62,7 @@ export const FormPage = ({
|
|||||||
{...css({
|
{...css({
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
|
flexShrink: 1,
|
||||||
backgroundColor: (theme) => theme.dark.background,
|
backgroundColor: (theme) => theme.dark.background,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
@ -36,7 +36,7 @@ import { useRouter } from "solito/router";
|
|||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
import { useYoshiki } from "yoshiki/native";
|
import { useYoshiki } from "yoshiki/native";
|
||||||
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
||||||
import { fullscreenAtom, Video } from "./state";
|
import { durationAtom, fullscreenAtom, Video } from "./state";
|
||||||
import { episodeDisplayNumber } from "../details/episode";
|
import { episodeDisplayNumber } from "../details/episode";
|
||||||
import { useVideoKeyboard } from "./keyboard";
|
import { useVideoKeyboard } from "./keyboard";
|
||||||
import { MediaSessionManager } from "./media-session";
|
import { MediaSessionManager } from "./media-session";
|
||||||
@ -104,6 +104,11 @@ export const Player = ({
|
|||||||
};
|
};
|
||||||
}, [setFullscreen]);
|
}, [setFullscreen]);
|
||||||
|
|
||||||
|
const setDuration = useSetAtom(durationAtom);
|
||||||
|
useEffect(() => {
|
||||||
|
setDuration(info?.durationSeconds);
|
||||||
|
}, [info, setDuration]);
|
||||||
|
|
||||||
if (error || infoError || playbackError)
|
if (error || infoError || playbackError)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -119,7 +119,6 @@ export const Video = memo(function Video({
|
|||||||
const setPrivateProgress = useSetAtom(privateProgressAtom);
|
const setPrivateProgress = useSetAtom(privateProgressAtom);
|
||||||
const setPublicProgress = useSetAtom(publicProgressAtom);
|
const setPublicProgress = useSetAtom(publicProgressAtom);
|
||||||
const setBuffered = useSetAtom(bufferedAtom);
|
const setBuffered = useSetAtom(bufferedAtom);
|
||||||
const setDuration = useSetAtom(durationAtom);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ref.current?.seek(publicProgress);
|
ref.current?.seek(publicProgress);
|
||||||
}, [publicProgress]);
|
}, [publicProgress]);
|
||||||
@ -217,9 +216,6 @@ export const Video = memo(function Video({
|
|||||||
setPrivateProgress(progress.currentTime);
|
setPrivateProgress(progress.currentTime);
|
||||||
setBuffered(progress.playableDuration);
|
setBuffered(progress.playableDuration);
|
||||||
}}
|
}}
|
||||||
onLoad={(info) => {
|
|
||||||
setDuration(info.duration);
|
|
||||||
}}
|
|
||||||
onPlaybackStateChanged={(state) => setPlay(state.isPlaying)}
|
onPlaybackStateChanged={(state) => setPlay(state.isPlaying)}
|
||||||
fonts={fonts}
|
fonts={fonts}
|
||||||
subtitles={subtitles}
|
subtitles={subtitles}
|
||||||
|
@ -167,13 +167,6 @@ func OrNull(str string) *string {
|
|||||||
return &str
|
return &str
|
||||||
}
|
}
|
||||||
|
|
||||||
func Max(x, y uint32) uint32 {
|
|
||||||
if x < y {
|
|
||||||
return y
|
|
||||||
}
|
|
||||||
return x
|
|
||||||
}
|
|
||||||
|
|
||||||
var SubtitleExtensions = map[string]string{
|
var SubtitleExtensions = map[string]string{
|
||||||
"subrip": "srt",
|
"subrip": "srt",
|
||||||
"ass": "ass",
|
"ass": "ass",
|
||||||
@ -315,7 +308,7 @@ func getInfo(path string, route string) (*MediaInfo, error) {
|
|||||||
Link: link,
|
Link: link,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Chapters: Map(make([]Chapter, Max(chapters_end-chapters_begin, 1)-1), func(_ Chapter, i int) Chapter {
|
Chapters: Map(make([]Chapter, max(chapters_end-chapters_begin, 1)-1), func(_ Chapter, i int) Chapter {
|
||||||
return Chapter{
|
return Chapter{
|
||||||
StartTime: ParseTime(mi.GetI(mediainfo.StreamMenu, 0, int(chapters_begin)+i, mediainfo.InfoName)),
|
StartTime: ParseTime(mi.GetI(mediainfo.StreamMenu, 0, int(chapters_begin)+i, mediainfo.InfoName)),
|
||||||
// +1 is safe, the value at chapters_end contains the right duration
|
// +1 is safe, the value at chapters_end contains the right duration
|
||||||
|
@ -68,7 +68,7 @@ func NewStream(file *FileStream, handle StreamHandle, ret *Stream) {
|
|||||||
ret.heads = make([]Head, 0)
|
ret.heads = make([]Head, 0)
|
||||||
|
|
||||||
length, is_done := file.Keyframes.Length()
|
length, is_done := file.Keyframes.Length()
|
||||||
ret.segments = make([]Segment, length, 2000)
|
ret.segments = make([]Segment, length, max(length, 2000))
|
||||||
for seg := range ret.segments {
|
for seg := range ret.segments {
|
||||||
ret.segments[seg].channel = make(chan struct{})
|
ret.segments[seg].channel = make(chan struct{})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user