feat(android): surface queue source on PlayerUiState
Reads MINSTREL_SOURCE_KEY from the current MediaItem's extras and
projects it as PlayerUiState.currentSource. PlayEventsReporter
needs this to tag plays with their originating system playlist
('for_you'/'discover'/'radio:<id>') so the server advances the
right rotation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,10 @@ class PlayerController @Inject constructor(
|
|||||||
override fun onEvents(player: Player, events: Player.Events) {
|
override fun onEvents(player: Player, events: Player.Events) {
|
||||||
val idx = player.currentMediaItemIndex
|
val idx = player.currentMediaItemIndex
|
||||||
val current = queueRefs.getOrNull(idx)
|
val current = queueRefs.getOrNull(idx)
|
||||||
|
val source = player.currentMediaItem
|
||||||
|
?.mediaMetadata
|
||||||
|
?.extras
|
||||||
|
?.getString(MINSTREL_SOURCE_KEY)
|
||||||
uiStateInternal.value =
|
uiStateInternal.value =
|
||||||
PlayerUiState(
|
PlayerUiState(
|
||||||
currentTrack = current,
|
currentTrack = current,
|
||||||
@@ -167,6 +171,7 @@ class PlayerController @Inject constructor(
|
|||||||
durationMs = player.duration.coerceAtLeast(0),
|
durationMs = player.duration.coerceAtLeast(0),
|
||||||
bufferedPositionMs = player.bufferedPosition.coerceAtLeast(0),
|
bufferedPositionMs = player.bufferedPosition.coerceAtLeast(0),
|
||||||
playbackError = player.playerError?.message,
|
playbackError = player.playerError?.message,
|
||||||
|
currentSource = source,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,4 +18,5 @@ data class PlayerUiState(
|
|||||||
val durationMs: Long = 0,
|
val durationMs: Long = 0,
|
||||||
val bufferedPositionMs: Long = 0,
|
val bufferedPositionMs: Long = 0,
|
||||||
val playbackError: String? = null,
|
val playbackError: String? = null,
|
||||||
|
val currentSource: String? = null,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user