From cfa875d816c686db05ad1657022f55391433915b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:11:21 +0000 Subject: [PATCH] docs: Add comprehensive comments to PlaybackService and WebTorrent Explained the architecture, watchdog mechanism, fallback strategy, and Service Worker integration logic. --- js/services/playbackService.js | 82 +++++++++++++++++++++++++++++++++- js/webtorrent.js | 23 ++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/js/services/playbackService.js b/js/services/playbackService.js index 933ee2cf..c0c0247d 100644 --- a/js/services/playbackService.js +++ b/js/services/playbackService.js @@ -1,6 +1,23 @@ import { userLogger } from "../utils/logger.js"; // js/services/playbackService.js +/** + * PlaybackService acts as the central conductor for video playback. + * It manages the lifecycle of a "PlaybackSession", which encapsulates the complex + * logic of attempting to play a video from a direct URL (HTTP/CDN) first, and + * falling back to a WebTorrent (P2P) stream if the URL is unreachable or stalls. + * + * Key Responsibilities: + * - Singleton-ish orchestration (only one active session at a time usually). + * - "Watchdog" monitoring: It attaches listeners to the