You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Surface end-of-media to hosts — the engine already tracks didReachEnd, then collapses it to .idle #63
A host that wants end-of-playback behavior (mark-watched, autoplay-next, return to the previous screen) can't distinguish "finished" from "idle" through the public API. Each playback host already tracks it — NativeAVPlayerHost.didReachEnd (@Published private(set)), and the Audio/Software hosts — but the engine consumes it internally (AetherEngine+Loading.swift: didReachEnd.filter { $0 }.sink { state = .idle }), so the public surface only ever shows .idle, indistinguishable from pre-load.
On the native path a host can work around it by observing the currentAVPlayer it's handed (AVPlayerItemDidPlayToEndTime). On the software-decode path there's no public AVPlayer to observe, so there's no host-side recourse at all.
Since the engine already has didReachEnd per host, could it surface end-of-media publicly — a terminal PlaybackState case (.ended), an engine-level @Published didReachEnd, or an onPlaybackEnded event? Any of those lets a host run end-of-playback handling on every backend without the AVPlayer workaround.
(The MinimalPlayer example treats .idle as stopped and re-enables Play, so it doesn't need the distinction — this only bites full hosts that act on end-of-media.)
PlaybackState now has a dedicated terminal case, .ended, set on end-of-media across every backend (native, software, audio) through the same wireCommonHostSinks path that previously routed didReachEnd to .idle. stop() still goes to .idle, so the two are now distinct: .ended means the source played to completion, .idle means pre-load or stopped. .ended is terminal, so seek and togglePlayPause are no-ops, and the next load(...) clears it.
Of your three suggestions I went with the terminal PlaybackState case rather than an engine-level @Published didReachEnd or an onPlaybackEnded event: end-of-media is mutually exclusive with playing/paused and fits the existing state machine cleanly, where the boolean overlays (isBuffering, isSeeking) are reserved for conditions that coexist with another state.
This went out as a major (4.0.0) on purpose. Adding a case to the non-frozen PlaybackState enum is source-breaking for an exhaustive switch that lacks an @unknown default, and shipping it as a major keeps from:-pinned adopters opting in deliberately instead of breaking on a routine swift package update. Migration is just adding case .ended wherever you previously treated .idle as end-of-media.
Thanks for the clear write-up, especially for calling out that the software-decode path has no public AVPlayer to observe, which is exactly what made this worth a first-class signal rather than a documented workaround.
Activity
feat(engine): surface end-of-media as PlaybackState.ended (#63)
chore(release): 4.0.0 — PlaybackState.ended (#63)
superuser404notfound commentedon Jun 24, 2026
Shipped in 4.0.0.
PlaybackStatenow has a dedicated terminal case,.ended, set on end-of-media across every backend (native, software, audio) through the samewireCommonHostSinkspath that previously routeddidReachEndto.idle.stop()still goes to.idle, so the two are now distinct:.endedmeans the source played to completion,.idlemeans pre-load or stopped..endedis terminal, soseekandtogglePlayPauseare no-ops, and the nextload(...)clears it.Of your three suggestions I went with the terminal
PlaybackStatecase rather than an engine-level@Published didReachEndor anonPlaybackEndedevent: end-of-media is mutually exclusive with playing/paused and fits the existing state machine cleanly, where the boolean overlays (isBuffering,isSeeking) are reserved for conditions that coexist with another state.This went out as a major (4.0.0) on purpose. Adding a case to the non-frozen
PlaybackStateenum is source-breaking for an exhaustiveswitchthat lacks an@unknown default, and shipping it as a major keepsfrom:-pinned adopters opting in deliberately instead of breaking on a routineswift package update. Migration is just addingcase .endedwherever you previously treated.idleas end-of-media.Thanks for the clear write-up, especially for calling out that the software-decode path has no public
AVPlayerto observe, which is exactly what made this worth a first-class signal rather than a documented workaround.fix(smb): use NWConnection-based SMBClient so SMB works on tvOS/iOS
fix(transport): park VOD seek-to-EOF at .paused and rewind on replay (s…
docs: the API reference the README kept pointing at