fix(android): enforce single active voice player in chat info tab
This commit is contained in:
@@ -2996,6 +2996,8 @@ private fun ChatInfoTabContent(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (tab == ChatInfoTab.Voice) {
|
if (tab == ChatInfoTab.Voice) {
|
||||||
|
var voiceTabActiveSourceId by remember(entries) { mutableStateOf<String?>(null) }
|
||||||
|
var voiceTabForceStopSourceId by remember(entries) { mutableStateOf<String?>(null) }
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -3052,11 +3054,28 @@ private fun ChatInfoTabContent(
|
|||||||
playbackTitle = entry.title,
|
playbackTitle = entry.title,
|
||||||
playbackSubtitle = entry.subtitle,
|
playbackSubtitle = entry.subtitle,
|
||||||
messageId = entry.sourceMessageId ?: entry.title.hashCode().toLong(),
|
messageId = entry.sourceMessageId ?: entry.title.hashCode().toLong(),
|
||||||
onPlaybackChanged = {},
|
onPlaybackChanged = { playback ->
|
||||||
forceStopAudioSourceId = null,
|
if (playback.isPlaying) {
|
||||||
|
val previous = voiceTabActiveSourceId
|
||||||
|
if (previous != null && previous != playback.sourceId) {
|
||||||
|
voiceTabForceStopSourceId = previous
|
||||||
|
}
|
||||||
|
voiceTabActiveSourceId = playback.sourceId
|
||||||
|
} else if (voiceTabActiveSourceId == playback.sourceId) {
|
||||||
|
voiceTabActiveSourceId = null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
forceStopAudioSourceId = voiceTabForceStopSourceId,
|
||||||
forceToggleAudioSourceId = null,
|
forceToggleAudioSourceId = null,
|
||||||
forceCycleSpeedAudioSourceId = null,
|
forceCycleSpeedAudioSourceId = null,
|
||||||
onForceStopAudioSourceHandled = {},
|
onForceStopAudioSourceHandled = { sourceId ->
|
||||||
|
if (voiceTabForceStopSourceId == sourceId) {
|
||||||
|
voiceTabForceStopSourceId = null
|
||||||
|
}
|
||||||
|
if (voiceTabActiveSourceId == sourceId) {
|
||||||
|
voiceTabActiveSourceId = null
|
||||||
|
}
|
||||||
|
},
|
||||||
onForceToggleAudioSourceHandled = {},
|
onForceToggleAudioSourceHandled = {},
|
||||||
onForceCycleSpeedAudioSourceHandled = {},
|
onForceCycleSpeedAudioSourceHandled = {},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user