Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to switch Audio Tracks in an HLS stream? #2628

Closed
sapanda opened this issue Mar 30, 2017 · 1 comment
Closed

Question: How to switch Audio Tracks in an HLS stream? #2628

sapanda opened this issue Mar 30, 2017 · 1 comment
Labels

Comments

@sapanda
Copy link

sapanda commented Mar 30, 2017

We currently use ExoPlayer 1.5.7, but are considering a switch to ExoPlayer 2.2. So this question applies equally to both.

We have several different audio tracks in a stream - segregated by language and a couple other factors. What's the best way to switch between tracks? Can this be done on the fly or would the entire content need to be re-prepared?

In ExoPlayer 2, we noticed that DefaultTrackSelector.selectAudioTrack() gets called by ExoPlayerImplInternal.handlePrepared(). So perhaps track selection can only be done right after a prepare? And is the best solution to create our own TrackSelector? Or is there an existing one that could easily fit the bill?

@AquilesCanta
Copy link
Contributor

As long as you are providing the alternative audio tracks demuxed (see #2014), you can either use a track selection override (have a look at the demo app for this) or set the according selection parameters to the default track selector:

selector.setParameters(selector.getParameters().withPreferredAudioLanguage("eng");

So perhaps track selection can only be done right after a prepare?

It can be done at any point. The demo app is a good example of this.

And is the best solution to create our own TrackSelector? Or is there an existing one that could easily fit the bill?

Unless you are doing seriously complicating the DefaultTrackSelector should provide what you need. You can even subclass it to override a specific track type selection.

Hope this helps.

@google google locked and limited conversation to collaborators Aug 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants