Repository navigation
Conversation
…r a transient loss
… who holds the play state
… rate change AVPlayer posts AVPlayerRateDidChangeNotification on the main queue before pause and setRate: return, so the backend's own changes were reported as the controls'. A macOS test pauses and plays a playing video's AVPlayer as its controls do and checks what the app hears.
houko
force-pushed
the
feat/video-system-pause
branch
from
November 16, 2026 04:34
ffd5609 to
9298add
Compare
A muted video, such as a looping background clip, has nothing to stop when headphones are unplugged, yet both backends paused it and held the pause until Paused changed, so it stayed still. Android now listens for ACTION_AUDIO_BECOMING_NOISY only while the video plays unmuted, and iOS pauses for a lost route only an unmuted video. The videos doc says so.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #276
What changed
core.Videoreports what the platform does to playback by itself:OnPause(VideoPauseReason)when its built-in controls, an interruption or a lost audio output pause it, andOnPlaywhen the controls or the system play it. TSX getsonPause({ reason })andonPlay, andnsgotestgetsPauseVideoandPlayVideoto report them headless.Pausedapplies when it changes and when a source opens. Between changes the platform's play state holds: a pause from the controls or the system is not undone by an unrelated prop change such as the volume, and a play from the controls whilePausedis true is not paused again. An app that shows its own play state follows the events inPaused, which takes the video back. When a transient interruption ends and the system allows it (iOS'sShouldResume, Android's focus coming back), a video still paused by it plays on and reportsOnPlay; a permanent focus loss and a lost output leave it paused.apple/videoplay.gokeeps who holds the play state and is unit tested. The backend followsAVPlayerRateDidChangeNotification(with its reason key for interruptions and backgrounding), iOS's interruption and route-change notifications, and ignores the rate drop at the item's end, whichOnEndreports. macOS reports itsAVPlayerViewcontrols through the same path.VideoNodeholds aMediaControlleror audio-focus pause without touching the app'spaused, keeps the focus request through a transient loss so it can play on, listens forACTION_AUDIO_BECOMING_NOISYonly while playing unmuted, and reports the controls' play.classes.dex/classes.jarrebuilt.EventImageInfoandEventMenuClosed, asEventMaskhas no free bit; the core routes them by view ID, and a removed video's report goes nowhere.Verification
go build ./...; Windows, Linux, wasm builds and Android/iOS vets of the touched packages;go tool nsgo check -target allgo tool nsgo testfor./core,./internal/driver,./internal/platform/apple,./internal/platform/android,./tsx,./nsgotest, and-run 'Layer|Skills|Doc' .TestVideoReportsWhatItsPlayerDidByItselfruns a realAVPlayerin a window, pauses and plays it as its controls do, and checks the pause holds through a volume change, the app's own pause and play are not reported, and the end reports no pause. It fails on the PR's first version.ControlsandAudioSessionplayback: controls pause reported once and held through a volume change; controls play reported; a timer alarm's transient focus paused it (interruption) and stopping the alarm played it on (OnPlay); after the app followed a pause withPausedthe alarm's end did not resume it; another app taking the focus for good paused it and it stayed paused; the app's own pause and play were not reported.Muted, on iOS and Android: a muted video, such as a looping background clip, has nothing to stop, and would otherwise stay paused untilPausedchanged.