Wholphin/app/src
Damontecres 26124a5348
Improve track selection logic (#1654)
## Description
Updates the logic for selecting tracks which should fix several edge
cases

The new logic groups track types together and then applying the user's
selection to the actual tracks in the file. For example, if the user
choosing the audio track which the server reports as absolute `index=2`
(eg the _third_ track of any type in the file) and audio `index=1` (eg
the _second audio_ track in the file), then the track selection logic
will use the _second audio_ track in the direct played file (after
accounting for id sorting).

Some other changes:
- If direct playing and an unsupported track is selected, the app will
now fall back to transcoding
- If the correct audio/subtitle tracks are not found, the app will now
fall back to transcoding instead of blocking any track change attempts

### TODO
Not necessarily in this PR, but some things need further investigation:
- Handling external audio tracks
- Why does ExoPlayer order the tracks differently sometimes, see
[example
here](https://github.com/damontecres/Wholphin/issues/791#issuecomment-4836470813)
where `0:3` is _after_ `0:4`, but the `MediaSourceInfo` lists them `0:3`
then `0:4`

### Related issues
Maybe fixes #791
Should fix
https://github.com/damontecres/Wholphin/issues/1005#issuecomment-4085440175
Related to the parent issue, #1475
Replaces #845

### Testing
Unit tests mostly, some basic tests on emulator

Needs more "real world" testing

#### Try it out?

You can try out this build by following the [instructions
here](https://github.com/damontecres/Wholphin/releases/tag/develop-track-selection).
If you do, please report your results in this PR!

## Screenshots
N/A

## AI or LLM usage
None
2026-07-10 17:49:47 -04:00
..
androidTest/java/com/github/damontecres/wholphin/test Fix issues when the system kills the app during playback (#1116) 2026-03-18 18:09:13 -04:00
appstore Dev: use build product flavors for app store release (#1205) 2026-04-06 15:24:20 -04:00
debug/res/values Dev: use build product flavors for app store release (#1205) 2026-04-06 15:24:20 -04:00
main Improve track selection logic (#1654) 2026-07-10 17:49:47 -04:00
test Improve track selection logic (#1654) 2026-07-10 17:49:47 -04:00