CHROMECAST.md
docs/features/CHROMECAST.md
1# Chromecast23Casting sends the current episode to Google Cast's Default Media Receiver4(`CC1AD845`) and queues the following episodes. The protocol, queue, status5parsing and discovery codec are shared in `services/media/cast`.67## Behavior89- The player's Cast button appears when the platform reports Cast support.10 Native platforms show a device dialog that runs discovery only while open;11 the web uses Chrome's own picker.12- Starting a cast pauses local playback, loads the current stream at the local13 position and appends up to two following episodes as their streams resolve.14 Leaving the player cancels unfinished extraction but not the cast.15- The cast panel replaces the centre controls. It shows the device and current16 item, with play/pause, seek, previous/next, a queue menu and Stop casting.17 In the minimized player it shows the compact form without the seek bar.18- Stopping the cast stops the receiver. If it was playing this episode, local19 playback seeks to the receiver's position.20- Subtitles: `.vtt` tracks are sent as text tracks. The selected track is21 enabled on the first item. The receiver's text style uses the stored player22 subtitle colours, bold/italic and font size (relative to 45).23- A stream is castable only when it is HTTP(S), needs no request headers and is24 not a device-local address. Otherwise another castable stream is chosen, or a25 notice explains that the episode cannot be cast.26- Failures are not retried. They surface as a notice or in the panel. Three27 missed heartbeats end the session.2829## Platforms3031| Platform | Implementation |32|---|---|33| Android | Shared CASTV2 client over TLS port 8009. mDNS discovery holds a Wi-Fi multicast lock (`CHANGE_WIFI_MULTICAST_STATE`). The Google Cast SDK is deliberately not used, which avoids a Play Services dependency and keeps one code path. |34| Desktop | Same CASTV2 client and mDNS discovery as Android. |35| iOS | Same CASTV2 session. Discovery uses `nw_browser` with Bonjour (`_googlecast._tcp`) and the connection uses Network.framework TLS. Requires the Local Network permission: `NSLocalNetworkUsageDescription` and `NSBonjourServices` in `Info.plist`. |36| Web | Chrome Cast Web Sender SDK, loaded lazily. Available only where the SDK reports Cast; the button is hidden elsewhere. |3738The receiver's self-signed certificate is accepted only on the Cast39connection. Chromecast device authentication is not implemented.4041## Limits4243- The Default Media Receiver fetches media itself, so it cannot use streams44 that need request headers or cookies. The local header proxy listens only on45 loopback.46- Non-VTT subtitles are not sent. Native discovery uses the default network47 interface.48- Progress is saved from local playback when the player closes, not49 continuously from the receiver.5051## Verification52532026-10-18: `CastProtocolTest` (6), `CastMdnsTest` (3) and `CastSessionTest`54(6) passed on desktop JVM and Kotlin/Wasm. They cover protobuf framing55round-trips, MEDIA_STATUS and queue mapping, VTT-only tracks and style colours,56mDNS name compression and truncation rejection, the handshake against a fake57transport, PONG replies and timeout/failure surfacing. Android, iOS simulator,58desktop and Wasm compiled. Casting to a real device was not exercised.59