improvements to the sleep timer
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
let error = $state<string | null>(null);
|
||||
let showResumeDialog = $state(false);
|
||||
let savedProgress = $state<{ positionSeconds: number; progressPercent: number } | null>(null);
|
||||
let nextEpisode = $state<MediaItem | null>(null); // Next episode for video skip button
|
||||
|
||||
let pollInterval: ReturnType<typeof setInterval> | null = null;
|
||||
let loadedItemId: string | null = null;
|
||||
@@ -408,6 +409,11 @@
|
||||
|
||||
isPlaying = true;
|
||||
loading = false;
|
||||
|
||||
// Fetch next episode for video episodes (for skip button)
|
||||
if (isVideo && currentMedia) {
|
||||
fetchNextEpisode(currentMedia);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("loadAndPlay error:", e);
|
||||
// Show detailed error including the full error object
|
||||
@@ -520,6 +526,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchNextEpisode(media: MediaItem) {
|
||||
nextEpisode = null;
|
||||
if (media.type !== "Episode" || !media.seriesId) return;
|
||||
try {
|
||||
const repo = auth.getRepository();
|
||||
const episodes = await repo.getNextUpEpisodes(media.seriesId, 1);
|
||||
if (episodes.length > 0 && episodes[0].id !== media.id) {
|
||||
nextEpisode = episodes[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch next episode:", e);
|
||||
}
|
||||
}
|
||||
|
||||
function handleSkipToNextEpisode() {
|
||||
if (nextEpisode) {
|
||||
goto(`/player/${nextEpisode.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(seconds: number): string {
|
||||
const hours = Math.floor(seconds / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
@@ -588,6 +614,8 @@
|
||||
onReportProgress={handleReportProgress}
|
||||
onReportStop={handleReportStop}
|
||||
onEnded={handleVideoEnded}
|
||||
hasNext={nextEpisode !== null}
|
||||
onNext={handleSkipToNextEpisode}
|
||||
/>
|
||||
<NextEpisodePopup />
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user