Skip to content

Commit 07707c2

Browse files
toniheirohitjoins
authored andcommitted
Ensure TrackSelectionParameters overrides match existing groups
The overrides specified by a MediaController may not use the exact same TrackGroup instances as known to the Player because the groups have been bundled to and from the controller. This bundling may alter the instance slightly depending on the version used on each side of the communication and the fields set (e.g. Format.metadata is not supported for bundling). This issue can be solved by creating unique track group ids for each group on the session side before bundling. On the way back, the groups in the track selection parameters can be mapped backed to their original instances based on this id. #minor-release Issue: androidx/media#296 PiperOrigin-RevId: 523986626
1 parent ded1206 commit 07707c2

File tree

1 file changed

+11
-0
lines changed
  • library/common/src/main/java/com/google/android/exoplayer2

1 file changed

+11
-0
lines changed

library/common/src/main/java/com/google/android/exoplayer2/Tracks.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ public boolean isTrackSelected(int trackIndex) {
189189
return mediaTrackGroup.type;
190190
}
191191

192+
/**
193+
* Copies the {@code Group} with a new {@link TrackGroup#id}.
194+
*
195+
* @param groupId The new {@link TrackGroup#id}
196+
* @return The copied {@code Group}.
197+
*/
198+
public Group copyWithId(String groupId) {
199+
return new Group(
200+
mediaTrackGroup.copyWithId(groupId), adaptiveSupported, trackSupport, trackSelected);
201+
}
202+
192203
@Override
193204
public boolean equals(@Nullable Object other) {
194205
if (this == other) {

0 commit comments

Comments
 (0)