fix: Watch state not saving on some items

This commit is contained in:
Aleksi Lassila
2024-12-23 05:58:19 +02:00
parent d72e3b37c4
commit dc295ed203
4 changed files with 19 additions and 10 deletions

View File

@@ -52,9 +52,9 @@
});
function reportProgress() {
if (video?.readyState === 4 && progressTime > 0 && videoDuration > 0)
if (video?.readyState === 4 && video?.currentTime > 0 && video?.duration > 0)
reiverrApiNew.users.updateMoviePlayStateByTmdbId($user?.id as string, tmdbId, {
progress: progressTime / videoDuration,
progress: video.currentTime / video?.duration,
watched: progressTime > 0.9
});
}
@@ -135,7 +135,7 @@
// ? `${$user?.settings.jellyfin.baseUrl}/Items/${item?.Id}/Images/Backdrop?quality=100&tag=${item?.BackdropImageTags?.[0]}`
// :
'',
startTime: stream.progress * stream.duration
progress: stream.progress
// (options.playbackPosition || 0) / 10_000_000 ||
// (item?.UserData?.PlaybackPositionTicks || 0) / 10_000_000 ||
// undefined

View File

@@ -28,7 +28,7 @@
// video.srcObject = null;
// hls?.destroy();
const { playbackUrl, directPlay, backdrop, startTime } = playbackInfo;
const { playbackUrl, directPlay, backdrop, progress } = playbackInfo;
if (backdrop) {
video.poster = backdrop;
@@ -55,9 +55,9 @@
video.src = playbackUrl;
}
if (startTime) {
progressTime = startTime;
}
// if (progress) {
// progressTime = startTime;
// }
}
function handleProgress() {
@@ -104,8 +104,14 @@
on:timeupdate={() => (progressTime = !seeking && videoDidLoad ? video.currentTime : progressTime)}
on:progress={handleProgress}
on:loadeddata={() => {
video.currentTime = progressTime;
// console.log('video loaded', video.currentTime, video.duration, playbackInfo?.progress);
// video.currentTime = progressTime;
videoDidLoad = true;
if (video.currentTime < video.duration * (playbackInfo?.progress || 0)) {
video.currentTime = video.duration * (playbackInfo?.progress || 0);
}
console.log('Video loaded');
}}
on:waiting={() => (buffering = true)}

View File

@@ -36,7 +36,7 @@ export type PlaybackInfo = {
playbackUrl: string;
directPlay: boolean;
backdrop?: string;
startTime?: number;
progress?: number;
audioStreamIndex: number;
audioTracks: AudioTrack[];