Skip to content

Conversation

@VelikovPetar
Copy link
Contributor

@VelikovPetar VelikovPetar commented Oct 23, 2025

🎯 Goal

The current implementation of the AudioPlayer is based on android.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

  • Adds exoplayer dependency to stream-chat-android-client
  • Replaces the usages of the MediaPlayer with ExoPlayer (inside the NativeMediaPlayerImpl wrapper)

🎨 UI Changes

NA

🧪 Testing

Test ALL features related to voice recording:

  1. Recording a new voice message (XML and Compose)
  2. Listen (with skipping, pausing and resuming) the recording before sending it to the channel
  3. Listen to already sent voice messages (with skipping, pausing and resuming) - both own and others
  4. Switch between playing different voice messages
  5. Send voice messages from iOS/React, and verify that they are playable on Android too

@github-actions
Copy link
Contributor

github-actions bot commented Oct 23, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.23 MB 5.18 MB 1.96 MB 🔴
stream-chat-android-offline 3.45 MB 5.45 MB 1.99 MB 🔴
stream-chat-android-ui-components 10.54 MB 10.55 MB 0.00 MB 🟢
stream-chat-android-compose 12.77 MB 12.77 MB 0.00 MB 🟢

@VelikovPetar VelikovPetar requested a review from Copilot October 23, 2025 15:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@VelikovPetar VelikovPetar requested a review from Copilot October 23, 2025 16:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@VelikovPetar VelikovPetar requested a review from Copilot October 23, 2025 16:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@VelikovPetar VelikovPetar marked this pull request as ready for review October 23, 2025 16:53
@VelikovPetar VelikovPetar requested a review from a team as a code owner October 23, 2025 16:53
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3.5% Coverage on New Code (required ≥ 80%)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@aleksandar-apostolov aleksandar-apostolov merged commit aefd03c into develop Nov 12, 2025
12 of 13 checks passed
@aleksandar-apostolov aleksandar-apostolov deleted the feature/AND-858_migrate_mediaplayer_to_exoplayer branch November 12, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants