Split software arch desc for easier manintenance. Many fixes related to next video playing and remote playback
🏗️ Build and Test JellyTau / Run Tests (push) Failing after 12s
🏗️ Build and Test JellyTau / Build Android APK (push) Has been skipped
Traceability Validation / Check Requirement Traces (push) Failing after 1s

This commit is contained in:
2026-03-01 19:47:46 +01:00
parent 3a9c126dfe
commit 09780103a7
45 changed files with 5663 additions and 3332 deletions
+14 -16
View File
@@ -18,7 +18,7 @@
reportPlaybackProgress,
reportPlaybackStopped,
} from "$lib/services/playbackReporting";
import { cleanup as cleanupNextEpisode, handleEpisodeEnded } from "$lib/services/nextEpisodeService";
import { cleanup as cleanupNextEpisode } from "$lib/services/nextEpisodeService";
const itemId = $derived($page.params.id);
const queueParam = $derived($page.url.searchParams.get("queue"));
@@ -62,25 +62,12 @@
let pollInterval: ReturnType<typeof setInterval> | null = null;
let loadedItemId: string | null = null;
// Handle next episode navigation event from popup
function handlePlayNextEpisode(event: Event) {
const customEvent = event as CustomEvent<{ episode: MediaItem }>;
const episode = customEvent.detail.episode;
if (episode) {
goto(`/player/${episode.id}`);
}
}
onMount(() => {
// Start position polling (only for audio via MPV backend)
pollInterval = setInterval(updateStatus, 1000);
// Listen for next episode navigation events
window.addEventListener("playNextEpisode", handlePlayNextEpisode);
return () => {
if (pollInterval) clearInterval(pollInterval);
window.removeEventListener("playNextEpisode", handlePlayNextEpisode);
};
});
@@ -92,6 +79,7 @@
$effect(() => {
const id = itemId;
if (id && id !== loadedItemId) {
console.log("[AutoPlay] $effect triggered: loading new item", id, "(was:", loadedItemId, ")");
loadAndPlay(id);
}
});
@@ -526,10 +514,20 @@
async function handleVideoEnded() {
// Call backend to handle autoplay decision (works on both Android and Linux)
// Pass the item ID and repository handle so the backend can look up the item
// and check for next episodes. HTML5 video plays independently of the Rust
// backend queue, so the backend needs these to know what just finished.
const mediaId = currentMedia?.id ?? null;
console.log("[AutoPlay] Video ended. currentMedia:", mediaId, currentMedia?.name, "itemId (URL):", itemId);
try {
await invoke("player_on_playback_ended");
const repo = auth.getRepository();
const repoHandle = repo.getHandle();
await invoke("player_on_playback_ended", {
itemId: mediaId,
repositoryHandle: repoHandle,
});
} catch (e) {
console.error("[VideoPlayer] Failed to handle playback ended:", e);
console.error("[AutoPlay] Failed to handle playback ended:", e);
}
}