Skip to content

Report when a video plays to its end - #51

Merged
514sid merged 1 commit into
mainfrom
completed-event
Nov 23, 2026
Merged

514sid merged 1 commit into
mainfrom
completed-event

Conversation

@514sid

@514sid 514sid commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Adds GaplessEvent.Completed(asset, playbackId), emitted when the video on screen reaches its end: a clip's last frame, or a stream that finished (video on demand, or a live stream the server marked as ended). The last frame stays on screen until the next play(), and Ended still follows when something replaces it.

Until now a host had no way to know a clip or stream was done, so the screen held its last frame until the host's own timer fired. With Completed it can cut to the next asset at once, which matters for streams of unknown length and clips shorter than their slot. On the TV, the sample clips complete 80 to 150 ms before their slot ends, which was a held last frame until now.

  • The engine reports the end only for the clip on screen, once per play. A staged clip, paused on its first frame, never counts.
  • The controller emits Completed only for its current asset; a report about one already replaced or stopped is dropped.
  • A live stream that simply stops arriving doesn't complete: it stalls, is retried and ends in PlaybackError, as before.
  • Images and web pages have no end and never complete.
  • The sample app logs it; its schedule still cuts on each slot's duration.

Adding a GaplessEvent subclass breaks exhaustive when expressions over it, so hosts need a new branch, as the sample app did.

Tests: the engine reports the end of the playing clip once, ignores a staged clip, and reports again for the next clip; the controller reports the current video and ignores one already replaced or stopped. Checked on the TV with the codecs playlist: Completed arrives before each Ended.

GaplessEvent.Completed fires when the clip on screen reaches its last
frame, or a stream finishes, while that frame stays up until the next
play(). Ended still follows when something replaces it. A host can now
cut to the next asset as soon as a clip or stream is done instead of
holding its last frame until its own timer fires, which matters for
streams of unknown length and clips shorter than their slot.

Only the clip on screen counts, once per play; a staged clip and a
report about a clip already replaced or stopped are ignored. A live
stream that just stops arriving still stalls and ends in PlaybackError.

Adding a GaplessEvent subclass breaks exhaustive when expressions over
it, so hosts need a new branch.
@514sid
514sid merged commit af44d05 into main Nov 23, 2026
1 check passed
@514sid
514sid deleted the completed-event branch November 23, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant