mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -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({
|
||||
flexDirection: "row",
|
||||
flexGrow: 1,
|
||||
flexShrink: 1,
|
||||
backgroundColor: (theme) => theme.dark.background,
|
||||
})}
|
||||
>
|
||||
|
@ -36,7 +36,7 @@ import { useRouter } from "solito/router";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { useYoshiki } from "yoshiki/native";
|
||||
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
||||
import { fullscreenAtom, Video } from "./state";
|
||||
import { durationAtom, fullscreenAtom, Video } from "./state";
|
||||
import { episodeDisplayNumber } from "../details/episode";
|
||||
import { useVideoKeyboard } from "./keyboard";
|
||||
import { MediaSessionManager } from "./media-session";
|
||||
@ -104,6 +104,11 @@ export const Player = ({
|
||||
};
|
||||
}, [setFullscreen]);
|
||||
|
||||
const setDuration = useSetAtom(durationAtom);
|
||||
useEffect(() => {
|
||||
setDuration(info?.durationSeconds);
|
||||
}, [info, setDuration]);
|
||||
|
||||
if (error || infoError || playbackError)
|
||||
return (
|
||||
<>
|
||||
|
@ -119,7 +119,6 @@ export const Video = memo(function Video({
|
||||
const setPrivateProgress = useSetAtom(privateProgressAtom);
|
||||
const setPublicProgress = useSetAtom(publicProgressAtom);
|
||||
const setBuffered = useSetAtom(bufferedAtom);
|
||||
const setDuration = useSetAtom(durationAtom);
|
||||
useEffect(() => {
|
||||
ref.current?.seek(publicProgress);
|
||||
}, [publicProgress]);
|
||||
@ -217,9 +216,6 @@ export const Video = memo(function Video({
|
||||
setPrivateProgress(progress.currentTime);
|
||||
setBuffered(progress.playableDuration);
|
||||
}}
|
||||
onLoad={(info) => {
|
||||
setDuration(info.duration);
|
||||
}}
|
||||
onPlaybackStateChanged={(state) => setPlay(state.isPlaying)}
|
||||
fonts={fonts}
|
||||
subtitles={subtitles}
|
||||
|
@ -167,13 +167,6 @@ func OrNull(str string) *string {
|
||||
return &str
|
||||
}
|
||||
|
||||
func Max(x, y uint32) uint32 {
|
||||
if x < y {
|
||||
return y
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
var SubtitleExtensions = map[string]string{
|
||||
"subrip": "srt",
|
||||
"ass": "ass",
|
||||
@ -315,7 +308,7 @@ func getInfo(path string, route string) (*MediaInfo, error) {
|
||||
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{
|
||||
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
|
||||
|
@ -68,7 +68,7 @@ func NewStream(file *FileStream, handle StreamHandle, ret *Stream) {
|
||||
ret.heads = make([]Head, 0)
|
||||
|
||||
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 {
|
||||
ret.segments[seg].channel = make(chan struct{})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user