Skip to content

fix(tv): leave the group instead of pausing it when the TV goes to standby - #382

Open
ChrisB85 wants to merge 1 commit into
chrisuthe:mainfrom
ChrisB85:fix/tv-standby-leaves-group
Open

ChrisB85 wants to merge 1 commit into
chrisuthe:mainfrom
ChrisB85:fix/tv-standby-leaves-group

Conversation

@ChrisB85

Copy link
Copy Markdown
Contributor

Problem

When an Android TV goes to sleep while it plays in a sync group, the whole group stops.

Android pauses the active media session on the way into standby. SendSpinPlayer forwards that as a controller pause, which applies to the group. Seen with 2.0.0 on a Mi Box (Android TV 11), in a group (sleep timeout) and playing alone (sleep key):

09.396 PowerManagerService: Going to sleep due to timeout
10.221 SendSpinPlayer: setPlayWhenReady: false
10.222 SendSpin: Sent: {"type":"client/command","payload":{"controller":{"command":"pause"}}}
       (three more pauses within 11 ms)
10.240 SendSpin: Received: stream/end

Change

A pause that arrives on a TV while it is not interactive sends client/leave ("to stop taking part in its group's playback") instead of pause:

state when the pause arrives sent
not a TV, or TV awake pause, as before
TV in standby, playing client/leave, once per burst
TV in standby, not playing nothing
leave cannot be sent pause, as before
same group still playing 1.5 s after the leave (server without client/leave) pause, as before

SendSpinPlayer.stop() sent pause twice (through setPlayWhenReady(false) and directly), which would have bypassed this. It now sends one.

Testing

  • New tests for each row, for the three pause routes of SendSpinPlayer and for the message itself; they failed before the change.
  • testDebugUnitTest :shared:testAndroidHostTest passes, assembleRelease builds.
  • This build has not been run on a TV yet.
  • The server side was checked with Music Assistant 2.10.13 and two aiosendspin 10.2.1 test clients sending the same messages:
TV's place in the group pause (now) client/leave (this PR)
follower group stops the other player keeps playing
leader group stops group still stops, see below
alone stops, play resumes at the position stops, play resumes at the position

Limitations

  • Leader: Music Assistant cancels the playback session when its owner changes group (SendspinPlayer._on_group_changed) without handing it over as set_members does. With that cancel disabled in a test server the other player kept getting audio after the leave. So this case needs a server fix as well; with this PR alone it behaves as before.
  • Music Assistant 2.10.0 and 2.10.5 ship aiosendspin 9.1.1, which has no client/leave; the fallback is for those. It is covered by unit tests only.
  • After waking, the TV stays out of the group until it is added again or switches back.
  • A deliberate pause from a remote controller while the TV is in standby also only takes the TV out of the group.

…andby

Android TV pauses the active media session on the way into standby. The
pause went to the server as a controller command and paused the whole
group. On a TV that is not interactive, send client/leave instead, and
fall back to pause if a server that predates the message ignores it.

SendSpinPlayer.stop() also sent its pause twice; it now sends one.

This branch has not been deployed

No deployments
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