feat(playback): add configurable timeout for initial playback start

Introduces a race condition between the primary playback source (URL or Torrent) and a configurable timeout. If the primary source fails to reach the 'playing' state within the timeout window, the system automatically falls back to the alternative source.

- Adds `DEFAULT_PLAYBACK_START_TIMEOUT` to instance config (3000ms).
- Updates `PlaybackService` to implement timeout logic using `withTimeout` wrapper.
- Ensures proper cleanup of stalled attempts (resetting video element, destroying torrent client).
This commit is contained in:
google-labs-jules[bot] committed 2026-01-26 15:55:11 +00:00
1 parent e795c74a8e
commit 7921ab6a2e
4 files changed
+87 -7

No files matched your search

+10
View File
@@ -436,3 +436,13 @@ export const ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS = 5 * 60;
* - "torrent": Try WebTorrent first, fall back to CDN/URL.
*/
export const DEFAULT_PLAYBACK_SOURCE = "url";
/**
* Timeout (in milliseconds) for the initial playback attempt.
*
* If the preferred source (URL or Torrent) does not reach the "playing" state
* within this window, the player will automatically switch to the fallback
* source. This prevents users from staring at a loading spinner indefinitely
* if the primary source is slow or stalled.
*/
export const DEFAULT_PLAYBACK_START_TIMEOUT = 3000;