Split software arch desc for easier manintenance. Many fixes related to next video playing and remote playback
This commit is contained in:
@@ -255,10 +255,14 @@ function createPlaybackModeStore() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor remote session for disconnection
|
||||
* Monitor remote session for disconnection with grace period.
|
||||
* Requires multiple consecutive misses before declaring disconnection
|
||||
* to tolerate transient network hiccups.
|
||||
*/
|
||||
function initializeSessionMonitoring(): void {
|
||||
// Subscribe to session changes
|
||||
let consecutiveMisses = 0;
|
||||
const DISCONNECT_THRESHOLD = 3; // ~6s at 2s polling interval
|
||||
|
||||
selectedSession.subscribe((session) => {
|
||||
const currentState = get({ subscribe });
|
||||
|
||||
@@ -266,14 +270,28 @@ function createPlaybackModeStore() {
|
||||
// Don't interfere during an active transfer (we intentionally clear the session)
|
||||
if (currentState.mode === "remote" && currentState.remoteSessionId && !currentState.isTransferring) {
|
||||
if (!session || session.id !== currentState.remoteSessionId || !session.supportsMediaControl) {
|
||||
console.warn("[PlaybackMode] Remote session lost or disconnected");
|
||||
update((s) => ({
|
||||
...s,
|
||||
mode: "idle",
|
||||
remoteSessionId: null,
|
||||
transferError: "Remote session disconnected",
|
||||
}));
|
||||
consecutiveMisses++;
|
||||
console.warn(`[PlaybackMode] Remote session miss ${consecutiveMisses}/${DISCONNECT_THRESHOLD}`);
|
||||
|
||||
if (consecutiveMisses >= DISCONNECT_THRESHOLD) {
|
||||
console.warn("[PlaybackMode] Remote session lost after sustained disconnection");
|
||||
consecutiveMisses = 0;
|
||||
update((s) => ({
|
||||
...s,
|
||||
mode: "idle",
|
||||
remoteSessionId: null,
|
||||
transferError: "Remote session disconnected",
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
// Session is healthy, reset counter
|
||||
if (consecutiveMisses > 0) {
|
||||
console.log("[PlaybackMode] Remote session recovered after", consecutiveMisses, "misses");
|
||||
}
|
||||
consecutiveMisses = 0;
|
||||
}
|
||||
} else {
|
||||
consecutiveMisses = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -228,15 +228,20 @@ export const mergedVolume = derived(
|
||||
/**
|
||||
* Should show audio miniplayer - state machine gated
|
||||
* Only true when:
|
||||
* 1. Player is in playing or paused state (not idle, loading, error)
|
||||
* 2. Current media is audio (not video: Movie or Episode)
|
||||
* 1. In remote mode with an active session playing media, OR
|
||||
* 2. Player is in playing or paused state (not idle, loading, error)
|
||||
* AND current media is audio (not video: Movie or Episode)
|
||||
*/
|
||||
export const shouldShowAudioMiniPlayer = derived(
|
||||
[player, currentMedia],
|
||||
([$player, $media]) => {
|
||||
const state = $player.state;
|
||||
[player, currentMedia, isRemoteMode, selectedSession],
|
||||
([$player, $media, $isRemote, $session]) => {
|
||||
// In remote mode, show if the remote session has a now-playing item
|
||||
if ($isRemote && $session?.nowPlayingItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only show when actively playing or paused
|
||||
// Local mode: only show when actively playing or paused
|
||||
const state = $player.state;
|
||||
if (state.kind !== "playing" && state.kind !== "paused") {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user