question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change Media with TextTracks on ExoPlayer v2.17.0 and v2.17.1

See original GitHub issue

Hi,

ExoPlayer Version: v2.17.0 and 2.17.1

I am having a single player instance, which I use to pass multiple medias. It helps me to do the change medias. I don’t use ExoPlayer’s Playlist feature. On UI, I show a spinner having multiple test tracks including ‘None’. None will disable the test tracks.

Let’s suppose 1st media is playing back and it has ‘None’ and I disabled the text track’s visibility. In the below code, what i do; i clear the selected indices which basically tells ExoPlayer not to display anything from that text group. Reference https://github.com/google/ExoPlayer/blob/8129675b065bc98330ec775fb7a538c139793070/library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectionOverrides.java#L123

//actually change track.
        TrackGroup trackGroup = mappedTrackInfo.getTrackGroups(rendererIndex).get(groupIndex);
        if (!selectedIndices.isEmpty()) {
            if (rendererIndex == TRACK_TYPE_TEXT && selectedIndices.get(0) == TRACK_DISABLED) {
                // Just clear the selected indices,
                // it will let exoplayer know that no tracks from trackGroup should be played
                selectedIndices.clear();
            }

            TrackSelectionOverrides.TrackSelectionOverride trackSelectionOverride = new TrackSelectionOverrides.TrackSelectionOverride(trackGroup, selectedIndices);

            TrackSelectionOverrides trackSelectionOverrides = trackSelectionOverridesBuilder
                    .setOverrideForType(trackSelectionOverride)
                    .build();

            parametersBuilder.setTrackSelectionOverrides(trackSelectionOverrides);
        } else {
            //clear all the selections if the override is null.
            trackSelectionOverridesBuilder.clearOverride(trackGroup);
        }
        selector.setParameters(parametersBuilder);

Issue: When i change the track (either same media or another one having text tracks), i see that for next track also text tracks are in the disabled state. Ex: Here i tried same content.

‘French’ is the default language having selection flag = 5 . So for the first time, trackSelected is true and next time trackSelected is false. I think Exo is again retaining some info for the trackgroups.

Screenshots:

Screenshot 2022-03-11 at 1 58 03 PM Screenshot 2022-03-11 at 1 58 43 PM

PS: Please update te ExoPlayer demo app for changing the tracks; it is still using the deprecated API setSelectionOverride

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Mar 14, 2022
1. Selected 'None' text tracks for the 1st media.
2. Clicked on the next from UI button.
3. For the 2nd media, No text track is visible however default text track is present in the next media.

In the demo app for current releases (e.g., 2.17), this is working as intended, because selecting “None” disables the renderer, and disabling the renderer is not tied to any specific TrackGroups.

I think your problem is probably to do with the way the new style selection overrides apply. Note that a new style override only specifies a single TrackGroup:

new TrackSelectionOverrides.TrackSelectionOverride(trackGroup, selectedIndices);

Note also that each of the text tracks is in its own group, because they present different content. So for an override to apply to the second piece of media, it’s only necessary that an equal TrackGroup is present to one you’ve set an override for in the first piece of media. This can be true even if the total number of available text tracks is different.

You need to make sure that when transitioning to the new piece of media, there aren’t any overrides present that apply to it. For example, create a new and empty TrackSelectionOverrides.Builder and make sure to incorporate it into the TrackSelectionParameters. This may be somewhat related to my earlier point about the line of code that I don’t think is doing anything.

1reaction
ojw28commented, Mar 13, 2022

Is the text TrackGroup in the second piece of media equal to the text TrackGroup in the first piece of media? If so then it’s working as intended that the override would continue to apply. If you don’t want the override to continue to apply, then you should update the parameters to get rid of it when you switch to playing the second piece of media.

Regarding the demo app, we are currently updating both the UI components and demo app to use the new track selection APIs (which, unfortunately, are changing a little again, since we didn’t get everything just how we wanted it the first time).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Releases · google/ExoPlayer - GitHub
An extensible media player for Android. Contribute to google/ExoPlayer development by creating an account on GitHub.
Read more >
Use Media Tracks | Cast - Google Developers
MediaTrack represents a media track, which can be an audio stream, a video stream, or text (such as subtitles or closed caption).
Read more >
RELEASENOTES.md · Gitee 极速下载/ExoPlayer - Gitee.com
Core library: Ensure that changing the ShuffleOrder with ExoPlayer.setShuffleOrder results in a call to Player.Listener#onTimelineChanged with reason=Player.
Read more >
ExoPlayer - bytemeta
Is it possible to receive dispatch commands from Voice? · Change Media with TextTracks on ExoPlayer v2.17.0 and v2.17.1.
Read more >
在Exoplayer v2.17.0和v2.17.1上使用TextTracks更改媒体
Change Media with TextTracks on ExoPlayer v2.17.0 and v2.17.1你好, Exoplayer版本:v2.17.0和2.17.1 我有一个单个播放器实例,我用来传递多个 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found