diff --git a/front/packages/ui/src/login/form.tsx b/front/packages/ui/src/login/form.tsx index b5e4f216c..45267eecf 100644 --- a/front/packages/ui/src/login/form.tsx +++ b/front/packages/ui/src/login/form.tsx @@ -62,6 +62,7 @@ export const FormPage = ({ {...css({ flexDirection: "row", flexGrow: 1, + flexShrink: 1, backgroundColor: (theme) => theme.dark.background, })} > diff --git a/front/packages/ui/src/player/index.tsx b/front/packages/ui/src/player/index.tsx index 506cdb095..e42f00bcc 100644 --- a/front/packages/ui/src/player/index.tsx +++ b/front/packages/ui/src/player/index.tsx @@ -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 ( <> diff --git a/front/packages/ui/src/player/state.tsx b/front/packages/ui/src/player/state.tsx index ea9781e5e..ee1aa3375 100644 --- a/front/packages/ui/src/player/state.tsx +++ b/front/packages/ui/src/player/state.tsx @@ -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} diff --git a/transcoder/src/info.go b/transcoder/src/info.go index 06643e02c..75f4a80f4 100644 --- a/transcoder/src/info.go +++ b/transcoder/src/info.go @@ -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 diff --git a/transcoder/src/stream.go b/transcoder/src/stream.go index 10a88ea9c..c1d8f0dd4 100644 --- a/transcoder/src/stream.go +++ b/transcoder/src/stream.go @@ -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{}) }