Question:How to set max bit rate in exoplayer v2
I am now doing the video app of dash, there is a requirement to let the user choose video quality there are 4 types (auto, high, medium,low), the high, medium,low will be configed in the backend.
I know there is a method in v1 DashRendererBuilder.setMaxBitrate(maxBitrate); but is there an easy way to set it in v2? Thanks.
We centralized everything to do with track selection in V2. Assuming you have a DefaultTrackSelector somewhere, you can set the maximum bitrate with:
trackSelector.setParameters(
trackSelector.getParameters().withMaxVideoBitrate(maxBitrate));
You should do this before calling player.prepare if you want this to affect the initial track selection.
@ojw28 Thanks for your answer. so you mean it will not affect when the user changes the quality during the playback? is it a way to change it during playback?
@ojw28 I tested this method, it also affects during playback, thank you very much. Great work!!!
@ojw28 when user select auto, what value should i set to this method? is it 0?
Use Integer.MAX_VALUE :).
Hi,
However i set withMaxVideoBitrate value before player.prepare, player still changes video profiles to higher than i set. For example i set 600.000. when i checked current video bitrate after i while i get 3.000.000.
The stream has 500.000,900.000,1.500.000,3.000.000 video formats
int maxBitrate=600000;
player.seekToDefaultPosition();
trackSelector.getParameters().withMaxVideoBitrate(maxBitrate);
player.prepare(mediaSource, !haveResumePosition, false);