Skip to content

Commit

Permalink
Fix exo track id parsing for format change.
Browse files Browse the repository at this point in the history
Without this changing to other audio tracks fails, it just keeps playing
the first one in the file. I was tipped off to the source of the problem
by lines like this in logcat:

11-04 19:26:01.244 11669 11669 D VideoManager: failed to parse track ID [0:2]

It appears exoplayer changed from a simple number for trackid to two
numbers separated by a colon. Haven't had any luck tracking down why,
but the latter of the two appears to match the old single number so,
just pull that out and use it.
  • Loading branch information
reacocard authored and nielsvanvelzen committed Nov 5, 2024
1 parent f474e2a commit 0d00adc
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,11 @@ public int getExoPlayerTrack(@Nullable org.jellyfin.sdk.model.api.MediaStreamTyp
if (trackFormat.id != null) {
int id;
try {
id = Integer.parseInt(trackFormat.id);
if (trackFormat.id.contains(":")) {
id = Integer.parseInt(trackFormat.id.split(":")[1]);
} else {
id = Integer.parseInt(trackFormat.id);
}
} catch (NumberFormatException e) {
Timber.d("failed to parse track ID [%s]", trackFormat.id);
break;
Expand Down Expand Up @@ -483,7 +487,11 @@ public boolean setExoPlayerTrack(int index, @Nullable org.jellyfin.sdk.model.api

int id;
try {
id = Integer.parseInt(trackFormat.id);
if (trackFormat.id.contains(":")) {
id = Integer.parseInt(trackFormat.id.split(":")[1]);
} else {
id = Integer.parseInt(trackFormat.id);
}
if (id != exoTrackID)
continue;
} catch (NumberFormatException e) {
Expand Down

0 comments on commit 0d00adc

Please sign in to comment.