Skip to content

Conversation

@VelikovPetar
Copy link
Contributor

🎯 Goal

Resolves a crash happening when attempting to play a video attachment from the SDK, while the integrator app includes the legacy com.google.android.exoplayer library.

Note: This was already fixed in the Compose SDK in #5841

Crash details:

  1. We are using the androidx.media3:media3-ui:1.6.1, while a customer is using the old com.google.android.exoplayer:exoplayer:2.13.3 (notice the package name difference)
  2. Both versions have the layout R.layout.exo_player_view used as a root view for the PlayerView . However, the one from media3 uses views from the androidx.media3.ui package, but the one from google uses views from the com.google.android.exoplayer2.ui package.
  3. In the integrator app, the R.layout.exo_player_view resource gets overridden by the one from google version, and when we try to render our own PlayerView , it fails to resolve the internal UIs, because they are different classes (from different package names).

Fix details:
Override the PlayerView properties: player_layout_id (default value is R.layout.exo_player_view) and the controller_layout_id (default value is R.layout.exo_player_control_view). We are overriding them with copied values from their default layouts, but we are using different layout IDs (stream_compose_exo_player_view and stream_compose_exo_player_control_view). This prevents the PlayerView layouts to be overridden by layouts from a different version of the library, because they now have a different name.

🛠 Implementation details

  1. Implement new stream_ui_exo_player_view and stream_ui_exo_player_control_view - copies of the default R.layout.exo_player_view and R.layout.exo_player_control_view
  2. Implement new base PlayerView layout stream_ui_player_view which uses the new root and controller layouts
  3. Create a new StreamPlayerView which Inflates the PlayerView from the stream_compose_player_view instead of directly instantiating the view (PlayerView(context))

🎨 UI Changes

Before After
before.mp4
after.mp4

🧪 Testing

  1. Apply the provided patch
  2. Run the Compose sample
  3. Open a channel with a video/audio attachment
  4. Click on the attached video/audio
  5. Click play - the video/audio should play and not crash
Provide the patch summary here
Index: stream-chat-android-ui-components-sample/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/stream-chat-android-ui-components-sample/build.gradle.kts b/stream-chat-android-ui-components-sample/build.gradle.kts
--- a/stream-chat-android-ui-components-sample/build.gradle.kts	(revision 8cc14b0418373a9a3737437eb37117bd87b2eef2)
+++ b/stream-chat-android-ui-components-sample/build.gradle.kts	(date 1763561447489)
@@ -181,4 +181,7 @@
     androidTestImplementation(libs.androidx.navigation.testing)
 
     detektPlugins(libs.detekt.formatting)
+
+    implementation("com.google.android.exoplayer:exoplayer:2.19.1")
+    implementation("com.google.android.exoplayer:exoplayer-ui:2.19.1")
 }

@VelikovPetar VelikovPetar marked this pull request as ready for review November 19, 2025 14:53
@VelikovPetar VelikovPetar requested a review from a team as a code owner November 19, 2025 14:53
@github-actions
Copy link
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.25 MB 5.25 MB 0.00 MB 🟢
stream-chat-android-offline 5.47 MB 5.47 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.58 MB 10.59 MB 0.01 MB 🟢
stream-chat-android-compose 12.81 MB 12.81 MB 0.00 MB 🟢

@sonarqubecloud
Copy link

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.

AttachmentMediaActivity crashes when opening .m4a files: ClassCastException between com.google.android.exoplayer2 and androidx.media3

2 participants