Skip to content

Commit a3f4b3d

Browse files
committed
Add toString to TrackGroup(Array)
These classes are often logged in error messages or tests. The current output is just the hash code which makes it hard to debug. PiperOrigin-RevId: 736799086 (cherry picked from commit 54c64b4)
1 parent f273930 commit a3f4b3d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

libraries/common/src/main/java/androidx/media3/common/TrackGroup.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ public boolean equals(@Nullable Object obj) {
161161
return id.equals(other.id) && Arrays.equals(formats, other.formats);
162162
}
163163

164+
@Override
165+
public String toString() {
166+
return id + ": " + Arrays.toString(formats);
167+
}
168+
164169
private static final String FIELD_FORMATS = Util.intToStringMaxRadix(0);
165170
private static final String FIELD_ID = Util.intToStringMaxRadix(1);
166171

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/TrackGroupArray.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public boolean equals(@Nullable Object obj) {
115115
return length == other.length && trackGroups.equals(other.trackGroups);
116116
}
117117

118+
@Override
119+
public String toString() {
120+
return trackGroups.toString();
121+
}
122+
118123
private static final String FIELD_TRACK_GROUPS = Util.intToStringMaxRadix(0);
119124

120125
public Bundle toBundle() {

0 commit comments

Comments
 (0)