Migrate MediaPlayer to ExoPlayer#5980
Conversation
SDK Size Comparison 📏
|
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the audio playback implementation from Android's MediaPlayer to ExoPlayer to support a wider range of audio codecs, particularly addressing issues with playing voice recordings that have mime-type "audio/mp4;codecs=opus".
Key changes:
- Replaces MediaPlayer with ExoPlayer in the NativeMediaPlayerImpl wrapper
- Updates StreamMediaPlayer to StreamAudioPlayer throughout the codebase
- Deprecates legacy MediaPlayer error constants in favor of PlaybackException error codes
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/AudioPlayerController.kt | Updates logger tag and reorders seekTo call after player setup |
| stream-chat-android-client/src/test/java/io/getstream/chat/android/client/audio/StreamMediaPlayerTest.kt | Renames StreamMediaPlayer to StreamAudioPlayer in tests |
| stream-chat-android-client/src/test/java/io/getstream/chat/android/client/audio/NativeMediaPlayerMock.kt | Updates error listener signature to match ExoPlayer's single errorCode parameter |
| stream-chat-android-client/src/main/java/io/getstream/chat/android/client/audio/StreamAudioPlayer.kt | Removes Android version checks and MediaPlayer-specific code |
| stream-chat-android-client/src/main/java/io/getstream/chat/android/client/audio/NativeMediaPlayer.kt | Complete reimplementation using ExoPlayer instead of MediaPlayer |
| stream-chat-android-client/src/main/java/io/getstream/chat/android/client/audio/AudioPlayer.kt | Updates parameter documentation from "hash" to "audioHash" |
| stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt | Updates audio player initialization to use ExoPlayer with proper audio attributes |
| stream-chat-android-client/src/test/java/io/getstream/chat/android/client/MockClientBuilder.kt | Updates mock to use StreamAudioPlayer type |
| stream-chat-android-client/build.gradle.kts | Adds ExoPlayer dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...hat-android-client/src/main/java/io/getstream/chat/android/client/audio/NativeMediaPlayer.kt
Outdated
Show resolved
Hide resolved
...hat-android-client/src/main/java/io/getstream/chat/android/client/audio/NativeMediaPlayer.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...in/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/AudioPlayerController.kt
Show resolved
Hide resolved
...hat-android-client/src/main/java/io/getstream/chat/android/client/audio/NativeMediaPlayer.kt
Show resolved
Hide resolved
...hat-android-client/src/main/java/io/getstream/chat/android/client/audio/NativeMediaPlayer.kt
Show resolved
Hide resolved
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...hat-android-client/src/main/java/io/getstream/chat/android/client/audio/NativeMediaPlayer.kt
Show resolved
Hide resolved
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt
Show resolved
Hide resolved
|




🎯 Goal
The current implementation of the
AudioPlayeris based onandroid.media.MediaPlayer. While this was working well in most cases, we had occurrences where a voice recoding could not be played (to be more specific:mime-type = "audio/mp4;codecs=opus"). By migrating to ExoPlayer we are able to play such files (+ potentially to support a wider range of codecs)🛠 Implementation details
exoplayerdependency tostream-chat-android-clientMediaPlayerwithExoPlayer(inside theNativeMediaPlayerImplwrapper)🎨 UI Changes
NA
🧪 Testing
Test ALL features related to voice recording: