Radoslav Ignatov
Radoslav Ignatov

Reputation: 143

Android ExoPlayer changing selected track

I am using Andorid ExoPlayer to stream content from internet through http(HLS). When I start the player it is working ok, but when I try to change the quality of the playing content -

player.setSelectedTrack(TYPE_VIDEO, 1)

for example, I get and HTTP 403 Forbidden error. If I initialize the player and run again the content, it is fine. I am using the Demo project as a source.

Do you know what might be causing this behavior and what is the difference in playing the initial stream and changing the track?

Is there a way to reset the streaming without re-initializing the whole player, because the url is passed to the builder when the player is initializing?

Upvotes: 1

Views: 5725

Answers (2)

Radoslav Ignatov
Radoslav Ignatov

Reputation: 143

I found the problem. The URL i was passing to the ExoPlayer was returned from an external API and was rather long so I haven't noticed that it is actually 2 URLs concatenated by "|"(http://my_url_1.m3u8|http://my_url_2.m3u8). The strange thing is that if you pass this string to the ExoPlayer it is playing a stream without error.. but if you try to change the quality of the playing stream you have problems.

Upvotes: 2

Habib
Habib

Reputation: 491

You do not change quality of the stream using setSelectedTrack(). That is used for selecting what to play from the available streams (like what language of audio, subtitle, or for videos it is quite rare, but for example you can set up different camera angles of a sport event).

All of these streams can have multiple quality levels, and ExoPlayer's FormatEvaluator selects what quality to download based on the network conditions.

If the decoder is different when you select a new track, then the player needs to be reinitialized for continuing playback.

I suggest downloading the HLS manifest (.m3u8) manually, and then check the listed information, try the urls one by one in a browser. All should work, you should not get 403 test in this test either.

Upvotes: 1

Related Questions