Fix voice message not resuming after playing voice recording in composer#6317
Fix voice message not resuming after playing voice recording in composer#6317
Conversation
…rding in composer
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/AudioPlayerController.kt (1)
81-84: Minor typo in log message.The semicolon after
currentPlayingIdshould likely be a colon for consistency with the other key-value pairs in this log statement.📝 Suggested fix
logger.d { - "[togglePlayback] audioHash: $audioHash, currentPlayingId; $currentPlayingId, " + + "[togglePlayback] audioHash: $audioHash, currentPlayingId: $currentPlayingId, " + "isCurrentTrack: $isCurrentTrack, isProgressRunning: $isProgressRunning, state: ${curState.stringify()}" }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/AudioPlayerController.kt` around lines 81 - 84, In AudioPlayerController's logging in the togglePlayback flow (see the logger.d block in AudioPlayerController.kt), change the typo in the log string so "currentPlayingId; $currentPlayingId" uses a colon instead of a semicolon for consistent key-value formatting (i.e., "currentPlayingId: $currentPlayingId"); no other behavior changes required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/AudioPlayerController.kt`:
- Around line 81-84: In AudioPlayerController's logging in the togglePlayback
flow (see the logger.d block in AudioPlayerController.kt), change the typo in
the log string so "currentPlayingId; $currentPlayingId" uses a colon instead of
a semicolon for consistent key-value formatting (i.e., "currentPlayingId:
$currentPlayingId"); no other behavior changes required.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 512ca0eb-22f7-4eb6-833a-573599011913
📒 Files selected for processing (1)
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/AudioPlayerController.kt
|



Goal
Fix voice message playback in the message list getting stuck after playing a voice recording in the composer.
Repro: play a voice message in the message list → while playing, play the voice recording in the composer → try to resume the message list one → it doesn't play. Playing a different message list track first unblocks the original one.
Implementation
The root cause is that
AudioRecordingController(composer recording preview) andAudioPlayerController(message list) both use the sharedAudioPlayersingleton independently. When the recording controller plays audio, it changesAudioPlayer.currentPlayingIdwithout the message list controller knowing. The message list controller's state still considers the interrupted track as "current and partially played", sotogglePlaybacktakes theresume()path — butAudioPlayer.resume()silently fails becausecurrentAudioHashno longer matches.audioPlayer.currentPlayingIdintogglePlaybackto detect when the underlying player has been taken over by another consumerplay()(full reload with seek) instead ofresume()Testing
Summary by CodeRabbit