fix(automotive): keep video from starting while a car is driving
DD-3 gives video no exemption: a restricted vehicle must not play it at all. The gate is read at the single point where media actually opens, so every path that can start a picture - an explicit play, a gapless arm, a track or channel switch, a frame-rate-match resume, a reload, and the queue navigation commands of the OS media session - is covered by one check rather than by a guard at each call site. A seek can also start playback with no play call, because mpv resumes when it seeks off the end of a file, so a restricted seek is followed by a pause. Watch Together needed the pause to be local. A vehicle stopping one peer is not a room-wide intent: a guest's forced pause is swallowed by the attachment's ledger rather than published, while a host's still pauses the room, because a host that kept broadcasting a frozen anchor would stall or rewind every guest it was meant to protect. The layer that owns a pause owns the resume for it, and one acknowledgement is recorded per event, so a surplus cannot eat the user's next real pause.
This commit is contained in:
@@ -128,7 +128,18 @@ extension _VideoPlayerLifecycleMethods on VideoPlayerScreenState {
|
||||
_wasPlayingBeforeInactive = _wasPlayingBeforeInactive || wasActive;
|
||||
if (wasActive) {
|
||||
try {
|
||||
await _pauseWithPlaybackIntent(currentPlayer);
|
||||
// On a car this is the driving transition itself, on every head unit whose vehicle cannot
|
||||
// report its restrictions. It is forced on this peer alone, so it must not travel to the
|
||||
// rest of a Watch Together room; elsewhere backgrounding keeps its existing meaning.
|
||||
if (isAutomotive) {
|
||||
if (await _pauseWithoutDisturbingTheRoom(currentPlayer)) {
|
||||
// The sync layer owns this pause and its resume. Drop the latch so the screen does not
|
||||
// also restore playback on the way back and ask the room to play along with it.
|
||||
_wasPlayingBeforeInactive = false;
|
||||
}
|
||||
} else {
|
||||
await _pauseWithPlaybackIntent(currentPlayer);
|
||||
}
|
||||
appLogger.d(
|
||||
'Video paused due to app being hidden '
|
||||
'(${isAutomotive
|
||||
|
||||
Reference in New Issue
Block a user