mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
feat(playback): record recently viewed only after the stream plays (#1732)
* feat(playback): record recently viewed only after the stream plays A channel, movie or episode used to enter Recently Viewed (and the dashboard's Continue Watching hero) the moment it was selected or its link was resolved, so streams that failed straight away cluttered the history. Writers now defer the write to a root PlaybackHistoryGate, keyed by the stream URL and/or the playback session key. The inline players confirm those keys once the owned engine's position has advanced by two seconds (seeks, stalls, pauses and a previous stream's progress do not count), the radio player does the same, and a launched MPV/VLC session confirms on `opened`/`playing`. M3U with MPV/VLC configured keeps recording on selection. Covers M3U (live, radio, movie detail), Stalker (live, radio, VOD, series), Xtream VOD and series, and the global live collection. The M3U host's embeddedPlayback is now compared by value: the history write updates the playlist meta mid-playback, and a new but identical playback object remounted the engine and restarted the stream. E2E flows that relied on recording-on-click now play local fixtures (HLS/TS/WebM routed in place of unreachable or public streams) and wait for confirmed playback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(playback): tighten recently viewed confirmation per review - Correlate by session key first: when both the deferred write and the confirmation carry a playbackSessionKey, only that is compared, so the same stream URL played in another playlist no longer records a failed attempt. URLs remain the fallback (portal writes, MPV/VLC sessions). The M3U radio player now receives the host's session key. - Count only playing progress: engines report `playing` (not paused, not seeking) with each time update, so short seeks of paused media no longer confirm a view. - Xtream: a write confirmed after a playlist switch still saves to its own playlist but no longer replaces the current playlist's recent list. - Global live tab: a row confirmed after another row was selected still moves to the top of an open Recently Viewed list (only a disposed tab skips the notification). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(playback): confirm session-keyed history only by its own session A write deferred with a playback session key (M3U) is now confirmed only by that key. The app-wide MPV/VLC session confirmation carries just the URL, so opening the same stream externally from another playlist could still commit an abandoned attempt. An "Open in MPV/VLC" recovery launch is instead confirmed by the WebPlayerViewComponent that requested it, under its own session key, once the launch has opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(playback): keep the history gate off the initial bundle The `@iptvnator/services` barrel ships in the initial bundle, so adding PlaybackHistoryGate there (and subscribing to it from the app-wide ExternalPlaybackService) grew renderer.initialBytes by 1,141 bytes. - Move the gate to a new lazy-only `playback-data-access` project (`@iptvnator/playback/data-access`; scope:shared, domain:playback, type:data-access) and register it in the coverage policy. - The gate subscribes to MPV/VLC session updates itself; it is created by the first deferred write, which precedes the launch it waits for. ExternalPlaybackService is back to master. - The Xtream "playlist switched before confirmation" check moves to the lazy helper; the initial-path store only takes a `skipListRefresh` flag. Net effect on this branch: +27 bytes over master (master itself is 108 bytes over the ratchet baseline already). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(playback): drop late Xtream confirmations off the initial path The Xtream store ships in the initial bundle, so even the small `skipListRefresh` flag cost 27 bytes there. A confirmation can only arrive after a switch to another playlist from a slow MPV/VLC launch (the inline player goes with the page), so the lazy helper now drops it instead: recording it would misfile the item or replace the other playlist's recent list. with-recent-items is back to master. This branch is now 3 bytes below master on renderer.initialBytes; the ratchet still reports master's pre-existing overage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(playback): pass the spec type-check gate from master - playback-data-access: align tsconfig.spec.json with the epg-data-access config #1705 updated (bundler resolution, global.d.ts for window.electron). - M3U recent-history spec: type the selectSignal override. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(playback): keep late Xtream confirmations in their own playlist history A confirmation that arrives after a switch to another playlist (a slow MPV/VLC launch) is no longer dropped: the lazy helper saves it to the captured playlist through the data source, without reloading the store's recent list, which belongs to the other playlist by then. The store and its barrel ship in the initial bundle, so the save path stays in the feature helper; renderer.initialBytes stays under the baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(playback): correlate global live-tab history by its session key The unified Favorites/Recent live tab deferred its history write by stream URL only, so the same URL played from another playlist could confirm a failed selection, and a switch to catch-up before confirmation could never match. It now defers with the tab's playlist-scoped playbackSessionKey (the key its players confirm with), and the tab's radio player receives it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(playback): keep MPV/VLC rows of the live tab confirmable by URL The live tab's session key can only be confirmed by its own inline players; MPV/VLC confirm the launched URL alone. A row that goes to an external player (also later, after a double-click) now defers by URL, and only rows played inline carry the session key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(playback): per-channel M3U history attempts, capability-based Xtream fallback - M3U: the recently-viewed dedupe key now includes the channel id, so a second row of the same URL defers its own write (its session key) and is recorded when it plays after the first row failed. - Xtream late write: key uncached content by Xtream id per supportsXtreamSqliteDataSource (the data-source factory's contract), not by a generic Electron bridge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: 4gray <fourgray@proton.me> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
61 files changed
+2362
-147
No files matched your search
@@ -1129,6 +1129,58 @@ This keeps:
|
||||
- series and VOD-as-series support intact
|
||||
- external MPV/VLC launches unchanged
|
||||
|
||||
## Recently Viewed Confirmation
|
||||
|
||||
Selecting or resolving an item is not watching it. A channel, movie or series
|
||||
becomes a recently viewed item — and with it the dashboard hero — only once
|
||||
its stream has really played, so a stream that fails straight away never
|
||||
reaches history.
|
||||
|
||||
- Writers do not persist on selection. They hand the write to
|
||||
`PlaybackHistoryGate` (`@iptvnator/playback/data-access`) with
|
||||
`defer(target, commit)`, where the target is what the playback will be
|
||||
known by: the host's `playbackSessionKey` (M3U) and/or stream URLs. The Stalker resolver defers
|
||||
by the resolved (possibly temporary) link; the persisted row still stores
|
||||
the portal `cmd`, never that link. Writers capture the item and its
|
||||
playlist when they defer, so navigating meanwhile cannot misfile it; an
|
||||
Xtream write confirmed after a switch to another playlist (only a slow
|
||||
MPV/VLC launch can) is saved to its own playlist without reloading the
|
||||
store's recent list, which belongs to the other playlist by then.
|
||||
- Matching: a write deferred with a session key is confirmed only by that
|
||||
same key — the same URL in two playlists must not let playback in one
|
||||
(inline, or in MPV/VLC) record a failed attempt in the other. Writes
|
||||
without one (portal resolvers) match any confirmation of their stream URL.
|
||||
The global live tab defers with its own playlist-scoped session key, which
|
||||
also survives a switch to catch-up, when the row plays inline; a row that
|
||||
goes to MPV/VLC defers by URL, the only thing that launch confirms.
|
||||
- `WebPlayerViewComponent` confirms its `playbackSessionKey`, `streamUrl`
|
||||
and `playback.streamUrl` once the owned engine's reported position has
|
||||
advanced by 2 seconds while playing (`PlaybackProgressConfirmation`).
|
||||
Engines report `playing` (not paused, not seeking) with each time update,
|
||||
so seeks of paused media do not count; neither do steps above 3 seconds
|
||||
(seeks, a resume jump, live-edge catch-up), stalls or backwards jumps. A
|
||||
report of a new stream never adds to the progress of the previous one; an
|
||||
engine or format swap of the same stream keeps its progress. The radio
|
||||
`AudioPlayerComponent` confirms the same way (with the host's session key
|
||||
when given).
|
||||
- MPV/VLC cannot report whether a live stream plays, so the gate itself
|
||||
subscribes to the Electron external-player session updates and confirms a
|
||||
session's `streamUrl` once it is `opened` or `playing`; a launch that ends
|
||||
in `error` is not recorded. (Subscribing in the gate, which the first
|
||||
deferred write creates, keeps it off the initial bundle.) That
|
||||
confirmation carries no session key, so an "Open in MPV/VLC" recovery
|
||||
launch is also confirmed by the `WebPlayerViewComponent` that requested
|
||||
it, under its own session key, once the launch has opened. M3U keeps
|
||||
recording on selection when MPV/VLC is the configured player.
|
||||
- A confirmation commits every write matching it, once. Unconfirmed writes
|
||||
are bounded (oldest dropped) and simply never commit. The global live tab
|
||||
moves a confirmed row to the top of an open Recently Viewed list even if
|
||||
another row was selected meanwhile.
|
||||
- A committed write updates the source while the item keeps playing. Hosts
|
||||
must not hand the player a new but identical playback for it: the M3U
|
||||
host's `embeddedPlayback` also reads the playlist meta, so it is compared
|
||||
by value — a new object would remount the engine and restart the stream.
|
||||
|
||||
## Playback Position Saving
|
||||
|
||||
The old dialog path saved playback positions from inside the removed Xtream
|
||||
|
||||
@@ -189,6 +189,14 @@ other utility projects, including shared interface contracts, while
|
||||
`ui-playback` and feature hosts may depend on it to render and execute
|
||||
session-local recovery actions.
|
||||
|
||||
`libs/playback/data-access` is the `playback-data-access` Nx project,
|
||||
imported through `@iptvnator/playback/data-access` (tags `scope:shared`,
|
||||
`domain:playback`, `type:data-access`). It owns renderer playback state that
|
||||
store, feature and player layers share — currently `PlaybackHistoryGate`,
|
||||
which holds "recently viewed" writes until playback is confirmed. It is kept
|
||||
out of `@iptvnator/services` on purpose: that barrel ships in the initial
|
||||
bundle, and this project is only reached from lazy player and portal code.
|
||||
|
||||
## Project Tags
|
||||
|
||||
Every Nx project keeps one tag from each family in `project.json`:
|
||||
|
||||
@@ -75,7 +75,10 @@ Render rules:
|
||||
full-bleed. All rails and the hero are skipped.
|
||||
3. The hero (`lib-dashboard-hero`) renders when it has at least one slide;
|
||||
see [Cinematic Hero](#cinematic-hero). It shows its own skeleton while
|
||||
the first history load runs.
|
||||
the first history load runs. An item enters recent history only after
|
||||
its stream has really played (see "Recently Viewed Confirmation" in
|
||||
`embedded-inline-playback.md`), so a channel that failed at once never
|
||||
becomes a hero slide.
|
||||
4. Each rail is emitted via `@if (cards.length > 0)`. Empty rails are hidden
|
||||
— there is no "empty widget" placeholder.
|
||||
5. Hero slides prefer a stored `backdrop_url`, then the TMDB backdrop; when
|
||||
|
||||
Reference in new issue
Block a user