feat(media_session): map Android PlaybackState 6 to buffering (t55)

The media session parser only understood states 2 (paused) and 3
(playing), so a session refilling its buffer (Android state 6, which the
Shield's own ExoPlayer/MediaSession sessions report exactly like stock
Android) read as "idle" or vanished into the foreground tier.

MediaSessionInfo gains an independent `buffering` flag (playing/paused/
buffering are now three flags off one integer), the session sort puts
buffering right behind playing — it is mid-playback, so it outranks a
paused session when the ladder picks one — and the running-apps
enrichment names a buffering live/last-known session "buffering" instead
of falling into "idle".

The MediaPlayerState stub gains BUFFERING and STANDBY so an in-suite
reference to a member real HA does not have fails here (real HA 2026.10
exposes off/on/idle/playing/paused/standby/buffering).
This commit is contained in:
James Mackay committed 2026-10-12 06:52:58 +01:00
1 parent 49bc23ae34
commit 07682ff082
4 files changed
+122 -9

No files matched your search

@@ -51,8 +51,11 @@ def running_apps_from_tasks(
if session:
if session.playing:
app["state"] = "playing"
elif session.buffering:
app["state"] = "buffering"
elif session.paused:
app["state"] = "paused"
app["state"] = "paused"
else:
app["state"] = "idle"
if session.title:
@@ -66,6 +69,8 @@ def running_apps_from_tasks(
if cached is not None:
if cached.playing:
app["last_known_state"] = "playing"
elif cached.buffering:
app["last_known_state"] = "buffering"
elif cached.paused:
app["last_known_state"] = "paused"
if cached.title: