Override default ExoPlayer layouts with custom ones to prevent overriding by other versions of the ExoPlayer library (XML). #6013
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



🎯 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:
androidx.media3:media3-ui:1.6.1, while a customer is using the oldcom.google.android.exoplayer:exoplayer:2.13.3(notice the package name difference)R.layout.exo_player_viewused as a root view for thePlayerView. However, the one frommedia3uses views from theandroidx.media3.uipackage, but the one fromgoogleuses views from thecom.google.android.exoplayer2.uipackage.R.layout.exo_player_viewresource gets overridden by the one fromgoogleversion, and when we try to render our ownPlayerView, it fails to resolve the internal UIs, because they are different classes (from different package names).Fix details:
Override the
PlayerViewproperties:player_layout_id(default value isR.layout.exo_player_view) and thecontroller_layout_id(default value isR.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_viewandstream_compose_exo_player_control_view). This prevents thePlayerViewlayouts to be overridden by layouts from a different version of the library, because they now have a different name.🛠 Implementation details
stream_ui_exo_player_viewandstream_ui_exo_player_control_view- copies of the defaultR.layout.exo_player_viewandR.layout.exo_player_control_viewPlayerViewlayoutstream_ui_player_viewwhich uses the new root and controller layoutsStreamPlayerViewwhich Inflates thePlayerViewfrom thestream_compose_player_viewinstead of directly instantiating the view (PlayerView(context))🎨 UI Changes
before.mp4
after.mp4
🧪 Testing
Provide the patch summary here