Introducing a new way to review your PRs.

Read the announcement

4gray / iptvnator

:tv: Cross-platform IPTV player application with multiple features, such as support of m3u and m3u8 playlists, favorites, TV guide, TV archive/catchup and more.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / media-playback

Media playback

Media playback turns a resolved live, movie, episode, or audio source into a watchable surface. It joins player choice, shared controls, platform support, recovery, and playback progress so the wider viewing experience can change sources without changing the viewer's basic interaction model. The electronic program guide, browser client, and television browsing and playback provide related host context.

Playback surfaces

Playback uses a surface that matches the source and the host platform. Browser video stays in the page. Desktop playback can use a managed MPV session. Android TV can hand a supported stream to the device player. Audio uses a focused station view. Supported desktop video can also show several streams at once.

This diagram shows how a resolved source reaches a playback surface and returns shared playback events.

flowchart LR
    A[Resolved source] --> B{Playback surface}
    B --> C[Inline browser video]
    B --> D[Audio station]
    B --> E[Embedded desktop video]
    B --> F[Android TV player]
    B --> G[External player session]
    E --> H[Multiview]
    C --> I[Shared controls and progress]
    D --> I
    E --> I
    F --> I
    G --> J[Runtime session state]

Inline video surfaces

Inline video renders inside the viewing page while the host keeps content state outside the player. HTML video, Video.js, and ArtPlayer report the same broad events for time, start, end, and playback failure. The host can therefore replace an engine without moving resume, episode, or source decisions into that engine. (libs/…/web-player-playback-events.ts• L27-80, libs/…/web-player-view.component.ts• L123-156)

Portal playback gives the video a stable theatre stage. It can center the video, show a safe poster image as ambient fill, or dock an Up Next rail when the stage has enough room. The portal header owns content actions such as source choice, stream copying, and closing the player. (libs/…/portal-inline-player.component.ts• L140-250, libs/…/portal-inline-player.component.html• L1-109, libs/…/portal-inline-player.scss• L89-160)

Series playback keeps the Up Next rail, the player card, and fullscreen episode navigation on one host selection path. The rail starts at the current episode and can continue into later seasons when those seasons are known. A viewer can move across a season boundary even when engine-local previous or next actions stop at the current season. (libs/…/portal-inline-player.component.ts• L214-257, libs/…/portal-inline-player.component.ts• L401-467, libs/…/up-next-rail.util.ts• L45-85)

References: libs/…/web-player-playback-events.ts• L27-80 libs/…/web-player-view.component.ts• L123-156 libs/…/portal-inline-player.component.ts• L140-257 libs/…/portal-inline-player.component.ts• L401-467 libs/…/portal-inline-player.component.html• L1-123 libs/…/portal-inline-player.scss• L89-160 libs/…/up-next-rail.util.ts• L45-85

On-demand entry actions

The VOD detail surface is the main entry point for on-demand playback. It lets the viewer play from the start, resume from saved progress, play a local download, or request a managed external player. It keeps these actions separate from the playback host so provider-specific code decides how to resolve the stream. (libs/…/vod-details.component.ts• L117-205, libs/…/vod-details.component.ts• L404-445, libs/…/vod-details.component.html• L101-212)

The detail surface does not allow a watched toggle to race with an active playback or launch request. This prevents a later position write from replacing a manual watched decision. (libs/…/vod-details.component.ts• L447-470)

References: libs/…/vod-details.component.ts• L117-205 libs/…/vod-details.component.ts• L296-348 libs/…/vod-details.component.ts• L404-470 libs/…/vod-details.component.html• L101-212

Audio station surfaces

Audio playback uses a focused station surface with artwork, station identity, transport actions, and volume. It can move to adjacent stations through the host and can receive volume changes from a parent surface. (libs/…/audio-player.component.ts• L29-172, libs/…/audio-player.component.ts• L186-228, libs/…/audio-player.component.ts• L318-375)

The station restores a saved volume and clamps every local or external volume update. It confirms recently viewed history only after the audio element reports real progress. A failed or unopened station therefore does not appear as watched content. (libs/…/audio-player.component.ts• L230-275, libs/…/audio-player.component.ts• L308-315, libs/…/audio-player.component.spec.ts• L385-431)

References: libs/…/audio-player.component.ts• L29-172 libs/…/audio-player.component.ts• L186-228 libs/…/audio-player.component.ts• L230-275 libs/…/audio-player.component.ts• L308-375 libs/…/audio-player.component.spec.ts• L385-431

Embedded desktop surfaces

Embedded desktop playback uses the Electron runtime to place a managed MPV session in the player area. The session can expose playback, tracks, subtitles, speed, aspect, recording, stream facts, and fullscreen actions when the runtime supports them. (libs/…/embedded-mpv-player.component.ts• L89-117, libs/…/embedded-mpv-controls.adapter.ts• L121-147, libs/…/embedded-mpv-player.component.html• L101-180)

The desktop surface treats live and on-demand playback as different behaviours. Live playback has no normal timeline or episode navigation. On-demand playback can seek and move through a series. A live MPEG transport stream can offer a jump toward the broadcast edge when the session reports enough buffered data. HLS does not use this action because its segment boundary can cause repeated stalls. (libs/…/embedded-mpv-controls.adapter.ts• L127-147, libs/…/embedded-mpv-live-edge.ts• L4-18, libs/…/embedded-mpv-live-edge.ts• L50-69)

The surface shows loading, stalled, reconnecting, ended, and failed states as viewer actions. A live stream that ends without an active reconnect is treated as a loss and offers retry rather than looking like a completed programme. (libs/…/embedded-mpv-controls-status.ts• L14-80, libs/…/embedded-mpv-player.component.html• L35-86)

References: libs/…/embedded-mpv-player.component.ts• L89-117 libs/…/embedded-mpv-controls.adapter.ts• L121-147 libs/…/embedded-mpv-controls-status.ts• L14-80 libs/…/embedded-mpv-live-edge.ts• L4-18 libs/…/embedded-mpv-live-edge.ts• L50-104 libs/…/embedded-mpv-player.component.html• L35-180

Android TV surfaces

Android TV playback can move a supported stream from the web player to the device's built-in player. The web surface suspends its own engine while the native session is pending, sends the stream request with safe provider headers and resume data, then accepts results only for the current playback identity. (libs/…/android-tv-playback.ts• L56-112, libs/…/android-tv-playback.ts• L243-361)

The native route is selective. It rejects protected or credential-bearing URLs, DASH, fresh-URL sources, and streams that the TV bridge cannot handle. It returns to the web player when the bridge rejects the request, becomes unavailable, parental lock is active, or the current session changes. It also carries position and end data back to normal progress and history handling. (libs/…/android-tv-playback.ts• L212-241, libs/…/android-tv-playback.ts• L134-190, libs/…/android-tv-playback.spec.ts• L344-413)

The native handoff keeps volume continuity. It passes the current and last audible volume to the TV player and restores them when playback returns to the web surface. (libs/…/android-tv-playback.ts• L254-301, libs/…/android-tv-playback.ts• L364-391)

On Android handheld hosts, the shared controls can expose a separate external-playback action. The action is available only when the Android shell exists and the current resolved stream can be transferred safely. (libs/…/android-external-action.ts• L3-11, libs/…/web-player-view.component.ts• L144-156)

References: libs/…/android-tv-playback.ts• L56-112 libs/…/android-tv-playback.ts• L134-190 libs/…/android-tv-playback.ts• L212-241 libs/…/android-tv-playback.ts• L243-391 libs/…/android-tv-playback.spec.ts• L344-413 libs/…/android-external-action.ts• L3-11 libs/…/web-player-view.component.ts• L144-156

Multiview surfaces

Multiview lets a desktop viewer open companion streams beside the primary stream. It supports picture-in-picture, side-by-side, grid, and focused layouts. The viewer can select which stream owns the controls and which stream supplies sound. (libs/…/second-stream-open-stream.ts• L4-24, libs/…/second-stream.component.ts• L87-156, libs/…/second-stream.component.html• L76-309)

The feature is available only when the primary MPV session uses the frame-copy surface. The viewer can add or replace a stream through a picker that browses live channels, EPG entries, and VOD or series content. The picker checks that the request is still current and rejects duplicates or sources that are no longer allowed. Stream identity uses the provider catalog for live and non-numeric VOD items, or content identity for numeric VOD and episode items. (libs/…/second-stream.component.ts• L93-101, libs/…/second-stream-picker-request.ts• L42-99, libs/…/second-stream-picker-vod.ts• L52-121, libs/…/second-stream-identity.ts• L4-80)

Only one stream is audible. A sound change first confirms that the old native session is muted before it enables the new one. If the view closes or becomes invalid during that handoff, the feature restores a safe mute state instead of leaving two streams audible. (libs/…/second-stream-audio.ts• L52-132, libs/…/embedded-mpv-audio-handoff.ts• L3-15)

Companion streams keep their own progress and recent-history confirmation. Closing a stream flushes its position before the slot is removed. A floating companion stays the same playback component while its surface moves into the top layer, so moving it does not restart playback. (libs/…/second-stream-slot-progress.ts• L14-77, libs/…/second-stream-slots.ts• L80-142, libs/…/second-stream-floating.directive.ts• L11-75)

References: libs/…/second-stream.component.ts• L57-183 libs/…/second-stream.component.ts• L263-401 libs/…/second-stream.component.html• L1-432 libs/…/second-stream-open-stream.ts• L4-24 libs/…/second-stream-picker-request.ts• L42-107 libs/…/second-stream-picker-vod.ts• L35-149 libs/…/second-stream-identity.ts• L4-80 libs/…/second-stream-audio.ts• L52-181 libs/…/second-stream-slot-progress.ts• L14-77 libs/…/second-stream-floating.directive.ts• L11-75

External player sessions

External playback hands a source to a managed desktop player instead of drawing it in the page. The web surface tracks launch, active, error, and closed states while the host runtime performs the handoff. (apps/…/external-playback.service.ts• L10-25, apps/…/external-playback.service.ts• L87-131)

Recovery offers an external player only when the runtime supports it and the source can be transferred safely. The inline view remains mounted while a handoff is pending, and it closes a current external session before starting a different one. (libs/…/web-player-recovery-controller.ts• L189-224, libs/…/web-player-view.component.external-recovery.spec.ts• L140-201)

When the external-player path needs local setup, the information dialog explains that the managed player is being used and links to installation guidance. The viewer can store a choice to hide that dialog on later launches. (libs/…/external-player-info-dialog.component.ts• L14-83)

References: apps/…/external-playback.service.ts• L27-131 libs/…/web-player-recovery-controller.ts• L85-224 libs/…/web-player-view.component.external-recovery.spec.ts• L140-286 libs/…/external-player-info-dialog.component.ts• L14-83

Shared playback controls

Shared controls give viewers one set of transport and presentation actions across browser, desktop, live, and on-demand playback. A player supplies current state and capabilities. The controls render only actions that the active player can perform.

Capability contract

The capability contract separates viewer actions from the engine that performs them. It covers transport, sound, tracks, subtitles, quality, presentation, recording, live-edge seeking, stream facts, and series navigation. (libs/…/player-controls.model.ts• L5-35, libs/…/player-controls.model.ts• L108-180)

CapabilityViewer result
TransportPlay, pause, seek, and timeline scrubbing when valid
Sound and tracksVolume, mute, audio tracks, subtitles, and subtitle files when available
PresentationSpeed, aspect ratio, picture-in-picture, and fullscreen when supported
Content flowPrevious and next episode actions for a series session
Live toolsJump to live edge, recording, and stream facts when reported
QualityManual rendition choice or return to automatic quality

The embedded MPV adapter derives this contract from runtime support and the playback type. It disables seeking and series navigation for live content and enables live-edge seeking only for supported live MPEG transport sessions. (libs/…/embedded-mpv-controls.adapter.ts• L121-147, libs/…/embedded-mpv-controls.adapter.spec.ts• L220-305)

References: libs/…/player-controls.model.ts• L5-35 libs/…/player-controls.model.ts• L108-180 libs/…/embedded-mpv-controls.adapter.ts• L121-147 libs/…/embedded-mpv-controls.adapter.spec.ts• L220-367

Control interaction

The controls adapt to the player box rather than the browser window. A narrow surface uses a compact dock and a volume popover. A wide surface keeps common actions visible. A settings panel appears beside a roomy player and becomes a bottom sheet when the player is too narrow. (libs/…/controls-layout.ts• L3-30, libs/…/player-controls.component.html• L121-153, libs/…/player-settings-panel.component.scss• L1-53)

Menus close when their capability disappears. The settings panel groups audio, subtitles, quality, speed, and aspect choices in one place. Keyboard focus enters the panel when a keyboard opened it and returns to the settings control when the panel closes. (libs/…/controls-menu-state.ts• L11-90, libs/…/player-settings-panel.component.ts• L88-145, libs/…/player-settings-panel.component.html• L21-428)

Pointer and keyboard input have different ownership rules. A mouse can reveal the controls and a plain viewport click can toggle playback after a short delay. A double-click uses the same surface for fullscreen. Touch reveals or hides the overlay without pausing the stream. Global shortcuts go to the player used most recently and yield to form fields, dialogs, inert regions, and host surfaces such as the programme guide. Escape closes an open popover or Up Next card first, while a suspended player also clears its open chrome before the host takes control. (libs/…/controls-surface.ts• L61-169, libs/…/controls-surface.ts• L316-375, libs/…/controls-shortcuts.ts• L79-225, libs/…/player-controls.component.ts• L247-265, libs/…/controls-suspension.ts• L1-33)

The surface tracks the source of focus and click events so a touch-generated hover event does not pin the controls. It also releases focus left by a pointer click without confusing that release with keyboard navigation. (libs/…/controls-surface.ts• L181-315)

Fullscreen belongs to a stable host surface when a player can be remounted during a source or episode change. Shared controls use the DOM fullscreen API when available and use native video fullscreen as a fallback on platforms that provide it. (libs/…/controls-fullscreen.ts• L16-65, libs/…/controls-fullscreen.ts• L125-145, libs/…/player-controls.component.ts• L73-85)

References: libs/…/controls-layout.ts• L3-77 libs/…/controls-menu-state.ts• L11-90 libs/…/controls-surface.ts• L61-169 libs/…/controls-surface.ts• L181-375 libs/…/controls-shortcuts.ts• L79-225 libs/…/controls-shortcuts.spec.ts• L67-186 libs/…/controls-suspension.ts• L1-33 libs/…/controls-fullscreen.ts• L16-145 libs/…/player-controls.component.ts• L73-85 libs/…/player-controls.component.dock.spec.ts• L139-235

Player compatibility controls

Browser players that use their own vendor chrome still receive the app's playback shortcuts. The adapter layer sends play, seek, volume, mute, and fullscreen actions to the active engine while keeping live streams and unknown-duration media from receiving invalid seek commands. (libs/…/legacy-player-shortcuts.ts• L7-71, libs/…/html-video-legacy-shortcuts.ts• L16-65, libs/…/vjs-legacy-shortcuts.ts• L11-89, libs/…/art-player-legacy-shortcuts.ts• L11-85)

Video.js also maps source tracks and quality choices into the shared control model. Caption preference applies at source start, while a source's own caption menu can take control after playback begins in vendor-chrome mode. (libs/…/vjs-player-controls.bridge.ts• L9-35, libs/…/vjs-player-controls.bridge.ts• L55-106, libs/…/vjs-text-tracks.ts• L20-33, libs/…/vjs-text-tracks.ts• L184-224)

References: libs/…/legacy-player-shortcuts.ts• L7-89 libs/…/html-video-legacy-shortcuts.ts• L16-91 libs/…/vjs-legacy-shortcuts.ts• L11-92 libs/…/art-player-legacy-shortcuts.ts• L11-88 libs/…/vjs-player-controls.bridge.ts• L9-106 libs/…/vjs-text-tracks.ts• L20-33 libs/…/vjs-text-tracks.ts• L184-224

Series and recording controls

The Up Next feature gives a series viewer a choice near the end of an episode. The host supplies the next item. The controls show it only for a series-capable, finite episode when the shared timing rule reaches the end window or closing credits. Live streams, open-ended media, ended episodes, hidden controls, and open settings suppress the card. (libs/…/controls-up-next.ts• L23-133, libs/…/up-next-timing.util.ts• L1-114)

The card shows the next episode's label, title, still, saved progress, and remaining-time countdown when autoplay is enabled. It can be dismissed for that next episode. If it remains on screen, it shrinks to a compact pill after a shared delay. Selecting it uses the host's normal next-episode path, so fullscreen and session ownership remain with the host. (libs/…/player-up-next-card.component.ts• L18-122, libs/…/player-up-next-card.component.html• L1-97, libs/…/player-controls.component.html• L608-628)

The portal builds a bounded Up Next rail from the current episode through later episodes and carries each raw episode back to the host. It waits when a season between the current and later episode is still loading. At a season boundary, manual selection and autoplay use the same rail path. An autoplay streak keeps consecutive automatic starts together and cancels a pending continuation when the viewer seeks, replays, chooses another episode, or the session changes. (libs/…/up-next-rail.util.ts• L30-85, libs/…/up-next-rail.util.ts• L94-149, libs/…/portal-inline-player.component.ts• L401-467, libs/…/autoplay-streak.service.ts• L1-16, libs/…/autoplay-streak.util.ts• L14-60)

Desktop live playback can also expose recording. The recording action belongs to the active frame-copy session and reports a clean stop with the channel or EPG context needed by the host. (libs/…/embedded-mpv-controls.adapter.ts• L341-365, libs/…/embedded-mpv-player.component.ts• L449-492, libs/…/embedded-mpv-player.component.ts• L830-894)

References: libs/…/controls-up-next.ts• L23-133 libs/…/up-next-timing.util.ts• L1-114 libs/…/player-up-next-card.component.ts• L18-122 libs/…/player-up-next-card.component.html• L1-97 libs/…/player-controls.component.html• L608-628 libs/…/controls-up-next.spec.ts• L117-241 libs/…/player-up-next-card.component.spec.ts• L46-275 libs/…/up-next-rail.util.ts• L30-149 libs/…/portal-inline-player.component.ts• L401-467 libs/…/portal-inline-player-up-next.spec.ts• L172-416 libs/…/autoplay-streak.service.ts• L1-16 libs/…/autoplay-streak.util.ts• L14-60 libs/…/embedded-mpv-controls.adapter.ts• L341-365 libs/…/embedded-mpv-player.component.ts• L449-492 libs/…/embedded-mpv-player.component.ts• L830-894

Player selection and runtime support

Playback chooses a player from the source form, the saved viewer preference, and the current runtime. Browser engines share one host boundary. Electron adds native playback, managed external players, request metadata, and frame-copy support. Android TV adds a selective native handoff without changing the shared control contract. Android handheld hosts can add an external-playback action when their shell can accept the current stream.

Source and player selection

The web view maps common source forms to suitable browser engines. Manifest-aware routes handle DASH and HLS. Transport streams use MPEG-TS support. Other media uses native browser support. When source metadata conflicts, the system keeps the source unknown instead of forcing an unsafe engine choice. (libs/…/playback-source-routing.ts• L4-45, libs/…/html-video-player.component.ts• L202-303, libs/…/vjs-player.component.ts• L312-380)

The saved browser player can change while a view is mounted. A desktop-only saved choice does not blank an existing inline session; it applies to a later host-owned playback choice. A portal host can also pass a resolved player before the web view mounts, which avoids a temporary default engine. (libs/…/web-player-view.component.ts• L242-251, libs/…/portal-inline-player.component.ts• L126-143)

References: libs/…/playback-source-routing.ts• L4-45 libs/…/html-video-player.component.ts• L202-303 libs/…/vjs-player.component.ts• L312-380 libs/…/web-player-view.component.ts• L242-251 libs/…/portal-inline-player.component.ts• L126-143

Platform runtime capabilities

Runtime capabilities describe what the current host can provide. A browser relies on browser media support. Electron can add native video, managed external players, frame-copy video, request metadata, and persistent desktop services. Android TV exposes a bridge only when its shell is present and playback is enabled. The web player uses these capabilities to decide which engines, external actions, and recovery choices are safe. (libs/…/runtime-capabilities.service.ts• L23-50, libs/…/runtime-capabilities.service.ts• L246-260, libs/…/playback-target-capabilities.ts• L64-99, libs/…/android-tv-playback.ts• L76-91, libs/…/android-external-action.ts• L3-11, libs/…/web-player-view.component.ts• L144-156)

Electron applies source request metadata before handing a stream to a browser or desktop session. Android TV applies the resolved provider headers to its native request after removing conflicting header values. Newer source work supersedes older handoffs so credentials do not reach the wrong stream. (libs/…/electron-stream-headers.service.ts• L18-107, libs/…/android-tv-playback.ts• L288-301, libs/…/web-player-view.component.recovery.spec.ts• L645-730)

References: libs/…/runtime-capabilities.service.ts• L23-50 libs/…/runtime-capabilities.service.ts• L246-260 libs/…/playback-target-capabilities.ts• L64-99 libs/…/android-tv-playback.ts• L76-91 libs/…/android-external-action.ts• L3-11 libs/…/web-player-view.component.ts• L144-156 libs/…/android-tv-playback.ts• L288-301 libs/…/electron-stream-headers.service.ts• L18-107 libs/…/web-player-view.component.recovery.spec.ts• L645-730

Desktop session lifecycle

An embedded MPV session starts only after support is known. It reports state through the Electron bridge and is tied to one player surface and one playback identity. The session is disposed when the source or surface changes, including when startup finishes after the view has already been replaced. (libs/…/embedded-mpv-session-controller.ts• L58-125, libs/…/embedded-mpv-session-controller.ts• L236-346)

Desktop video can use a native layer or copy frames into the page. Native layers need fresh bounds after resize, scroll, layout drift, and display-scale changes. Frame-copy video follows the DOM and lets controls, dialogs, multiview, and fullscreen overlays stack above the canvas. (libs/…/embedded-mpv-session-controller.ts• L128-239, libs/…/embedded-mpv-player.component.ts• L510-525)

References: libs/…/embedded-mpv-session-controller.ts• L58-125 libs/…/embedded-mpv-session-controller.ts• L128-239 libs/…/embedded-mpv-session-controller.ts• L236-346 libs/…/embedded-mpv-player.component.ts• L510-525

Playback recovery and continuity

Recovery and continuity protect the viewer from source failures and player changes. The system keeps a stable logical session, accepts events only from the current playback owner, and turns failures into a small set of source, player, or retry choices.

Recovery decisions

The active engine reports a diagnostic. The web player records it for the current source and application session. A recovery policy then considers the failure type, earlier attempts, alternative sources, transfer rules, and runtime support before it shows an action. (libs/…/web-player-recovery-controller.ts• L53-103, libs/…/web-player-recovery-controller.ts• L150-224)

Recovery does not reuse events from a replaced engine. It also supports one advertised MPEG-TS fallback for an initial terminal live HLS failure. Once real playback has started, a later failure remains visible instead of silently changing the source. Recovery state resets for a new session key, while a source revision within the same session resets only the resume clock. (libs/…/web-player-view.component.live-format.spec.ts• L300-378, libs/…/playback-recovery-session.ts• L41-79, libs/…/playback-recovery-session.ts• L126-175)

This diagram shows how a player failure becomes a safe viewer action.

sequenceDiagram
    participant Engine as Active player
    participant View as Web player
    participant Policy as Recovery policy
    participant Viewer
    participant Host as Source or runtime host

    Engine->>View: Playback diagnostic
    View->>Policy: Source, attempts, capabilities
    Policy-->>View: Retry, player, or source choices
    View-->>Viewer: Recovery surface
    Viewer->>View: Selects an action
    View->>Host: Retry, source change, or handoff
    Host-->>View: New session state

References: libs/…/web-player-recovery-controller.ts• L53-103 libs/…/web-player-recovery-controller.ts• L150-246 libs/…/playback-recovery-session.ts• L41-175 libs/…/web-player-view.component.live-format.spec.ts• L300-408 libs/…/web-player-view.component.recovery.spec.ts• L525-604

Session identity and progress

A playback session key identifies logical content rather than one provider copy or URL. This lets a viewer change source or player without creating a new logical watch session. Non-live web playback saves resume progress after the requested starting position settles and flushes the final position when content changes or the view ends. (libs/…/playback-session-key.ts• L1-37, libs/…/web-player-activity.ts• L8-83)

The web player accepts time updates only from the current source and player application. Its playback-event boundary records owned position, start, and end events for recovery, progress, history, and host outputs. It ignores startup ticks until a resume seek settles, then accepts later rewinds as real playback. Android TV checkpoints and companion MPV streams use the same progress ideas but keep a separate activity identity for each slot. A reconnecting end flushes progress without completing the programme. (libs/…/web-player-playback-events.ts• L27-80, libs/…/web-player-view.component.ts• L343-375, libs/…/playback-recovery-session.ts• L108-124, libs/…/second-stream-slot-progress.ts• L49-71, libs/…/android-tv-playback.ts• L151-189)

References: libs/…/playback-session-key.ts• L1-37 libs/…/web-player-activity.ts• L8-83 libs/…/web-player-playback-events.ts• L27-80 libs/…/web-player-view.component.ts• L343-375 libs/…/playback-recovery-session.ts• L108-124 libs/…/second-stream-slot-progress.ts• L14-71 libs/…/android-tv-playback.ts• L151-189

Recently viewed confirmation

Recently viewed history is deferred until playback is confirmed. Inline video and audio confirm after at least two seconds of real position advance. External playback confirms when the managed session opens or starts. The history gate matches a known session key strictly and uses a stream URL only for writers that do not know the host session. (libs/…/playback-history-gate.service.ts• L31-129, libs/…/playback-history-confirmation.ts• L19-57, libs/…/playback-progress-confirmation.ts• L1-71)

Engine position jumps do not count as watched time. Pauses, stalls, seeks, and backward jumps add no progress. A source or player revision can keep progress already seen while starting a new position clock. This prevents a resolved or failed link from becoming watched content and prevents a source switch from confirming the wrong record. (libs/…/playback-progress-confirmation.ts• L1-71, libs/…/playback-history-confirmation.ts• L40-57)

References: libs/…/playback-history-gate.service.ts• L31-129 libs/…/playback-history-confirmation.ts• L19-57 libs/…/playback-progress-confirmation.ts• L1-71 libs/…/audio-player.component.ts• L308-315 libs/…/second-stream-slot-progress.ts• L41-70

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the shared capability flags aligned with both the controls that render actions and the engine commands that perform them.
  • Keep live detection aligned across portal metadata, embedded MPV state, seekability, recording, live-edge seeking, and episode navigation.
  • Keep Up Next timing aligned across shared timing rules, the player card, the portal rail, autoplay state, and the TV client.
  • Keep Up Next dismissal and collapse identity aligned with the current episode and the next episode it points to.
  • Keep series navigation aligned across season-local transport actions, rail selection, fullscreen episode selection, lazy season loading, and autoplay.
  • Keep multiview identity checks aligned with picker results, provider catalog identity, content identity, duplicate detection, and slot state.
  • Keep multiview audio ownership aligned with slot creation, replacement, close, and session teardown. A handoff must not enable the incoming stream before the outgoing mute is confirmed.
  • Keep frame-copy availability aligned with fullscreen panels, multiview, native overlays, and the player surface that owns controls.
  • Keep native MPV bounds aligned with layout movement, scroll, resize, and device-scale changes. Do not apply native-view workarounds to frame-copy canvases.
  • Keep recovery recommendations aligned with runtime player support, transfer safety, attempted targets, and source type.
  • Keep application ownership aligned with source revision, player generation, retry state, suspension state, and time-update forwarding.
  • Keep request metadata scoped to the current stream and clear it when the stream or player changes.
  • Keep Android TV admission rules aligned with URL form, DRM, fresh-URL needs, parental lock, bridge availability, headers, checkpoints, and return-to-web behaviour.
  • Keep Android handheld external-action availability aligned with shell support, the current resolved stream URL, and transfer safety.
  • Keep Android TV session IDs and playback tokens aligned so late native results cannot update a new web session.
  • Keep native and vendor-chrome fullscreen paths aligned with the stable fullscreen host and the video fallback path.
  • Keep keyboard shortcut ownership aligned with inert or suspended host surfaces, interactive controls, and the active player instance.
  • Keep history confirmation tied to real position advance rather than a play event, source resolution, or a failed session.

Important failure modes

TriggerConsequenceGuard
A control renders without the matching capabilityThe viewer can request an action the engine cannot performDerive menu visibility and commands from the current capability contract
A live session exposes VOD seek or episode actionsThe viewer sees a timeline or navigation that has no valid targetResolve live state before deriving duration, seek, and series capabilities
A frame-copy player is treated like a native layerOverlays are hidden or the canvas is resized for a workaround it does not needKeep frame-copy and native surface rules separate
A native MPV window misses a position or display-scale changeVideo appears away from the page playerResync bounds after layout drift and device-scale changes
Live HLS uses the MPEG-TS live-edge actionThe stream can stall at a segment boundaryOffer live-edge only for live MPEG transport sessions
A reconnecting MPV end is treated as a completed episodeAutoplay skips the rest of the episodeSuppress end behaviour while reconnect metadata is present
Up Next timing differs between clientsThe card or autoplay starts at different points on different platformsUse the shared timing rule and collapse delay
Up Next is offered for live or open-ended mediaThe viewer sees a countdown with no valid endRequire a finite episode duration and series capability
Season-crossing autoplay ignores a pending load or a new viewer actionA stale episode starts after the viewer has moved or soughtHold the session identity and cancel pending autoplay on seek, replay, selection, or session change
Multiview unmutes the new stream before the old mute completesTwo streams are audible or the wrong stream remains audibleSerialize mute then unmute and validate both sessions before each step
A multiview request finishes after its route or slot changedA stale picker replaces the current companion streamRecheck request epoch, route, slot, permission, and duplicates before accepting
A companion slot closes without flushing progressResume state and recent history lose the last positionRetire the sound owner and flush slot progress before removal
A player event arrives from an old source or generationOld progress or errors change the current playbackRequire current application, source revision, and player ownership
A stale Electron or Android header handoff completes after a source changeOld credentials reach a new source or the new source starts without themAccept only the newest handoff and clear the old scope
Android TV receives an unsupported or protected URLThe native launch fails or cannot carry the sourceCheck bridge support, URL rules, DRM, and fresh-URL requirements before handoff
An Android handheld external action stays available for a non-transferable streamThe viewer starts a native route that cannot accept the current sourceDerive availability from the current shell and resolved playback transfer check
A late Android TV result is accepted after return to webOld position or end data changes the new web playerMatch the native result to the current session ID and playback token
Recovery offers MPV or VLC without runtime support or safe transferThe selected fallback cannot start or cannot carry the sourceBuild recommendations from runtime capability and transfer rules
A source is confirmed in history before real position advanceA dead link appears as watched contentRequire measured playback progress before confirmation
A touch tap is handled as mouse hover or click-to-pauseControls stay pinned or the stream pauses when the viewer meant to reveal controlsTrack pointer type and use touch-specific overlay rules
A focused guide, dialog, inert, or suspended surface does not own keyboard inputPlayer shortcuts change a hidden or unrelated streamYield shortcuts to interactive, inert, and explicitly suspended host surfaces
Fullscreen is owned by a player element that is remountedFullscreen exits during an episode, channel, or source switchGive the stable player host the fullscreen target

Key files

FileWhy to read it
libs/…/index.tsPublic playback entry point for player surfaces, controls, portal playback, and shared playback utilities
libs/…/web-player-view.component.tsMain boundary for engine selection, source handoff, ownership, progress, recovery, native TV handoff, handheld external playback, and fullscreen persistence
libs/…/web-player-playback-events.tsShared event boundary for owned player time, start, end, history, recovery, and host notifications
libs/…/web-player-view.component.htmlPlayer mounting, embedded desktop integration, multiview placement, recovery surface, and Android TV actions
libs/…/portal-inline-player.component.tsPortal playback context, theatre stage, source actions, series navigation, Up Next handoff, and season-crossing autoplay
libs/…/up-next-rail.util.tsOrdered episode rail data, season spillover, progress, and pending-season handling
libs/…/autoplay-streak.service.tsWeb and desktop service boundary for shared autoplay-run tracking
libs/…/vod-details.component.tsOn-demand play, resume, local playback, external playback, and watched-state entry actions
libs/…/embedded-mpv-session-controller.tsDesktop runtime support, session lifecycle, frame-copy startup, native positioning, and teardown
libs/…/embedded-mpv-controls.adapter.tsMapping from desktop session state to shared controls and runtime capabilities
libs/…/embedded-mpv-player.component.tsDesktop viewer state, live and series rules, recording, fullscreen, and session events
libs/…/audio-player.component.tsAudio station surface, volume, adjacent stations, and playback confirmation
libs/…/second-stream.component.tsMultiview layouts, slot selection, sound ownership, picker entry, and companion progress
libs/…/second-stream-identity.tsStable identity rules used to reject duplicate companion streams
libs/…/second-stream-slot-progress.tsCompanion resume progress, history confirmation, and close-time flush
libs/…/second-stream-picker-request.tsCurrent-request, route, permission, and duplicate checks for adding and replacing companion streams
libs/…/player-controls.model.tsShared capability, state, command, title, timeline, and Up Next contracts
libs/…/player-controls.component.tsCommon controls, interaction ownership, menus, responsive layout, volume, fullscreen, and Up Next wiring
libs/…/controls-surface.tsSurface pointer semantics for reveal, touch overlay behavior, viewport play/pause, fullscreen, and popover dismissal
libs/…/android-external-action.tsContract for exposing safe Android handheld external playback from shared controls
libs/…/controls-shortcuts.tsGlobal shortcut ownership, Escape handling, and keyboard opt-out rules
libs/…/player-up-next-card.component.tsViewer-facing next-episode card, countdown, dismissal, and collapse behavior
libs/…/up-next-timing.util.tsShared timing rule that keeps the Up Next window consistent across clients
libs/…/autoplay-streak.util.tsShared rules for continuing or resetting consecutive autoplay
libs/…/android-tv-playback.tsAndroid TV admission, native launch, result handling, checkpoint handoff, and return to web
libs/…/playback-recovery-session.tsSession reset, player generations, attempted targets, retry, and resume continuity
libs/…/web-player-application-ownership.tsRules that reject events from replaced or suspended playback applications
libs/…/web-player-activity.tsResume progress, content-session changes, and final position flushes
libs/…/playback-progress-confirmation.tsRule for proving that a stream really advanced before history confirmation
libs/…/playback-history-gate.service.tsDeferred recently viewed writes and strict confirmation matching