angel_30
angel_30

Reputation: 1

Get bitrate estimate with ExoPlayer Android API

I have the following code that uses ExoPlayer 2.4.0 API that simply plays a MPEG-DASH video. As I understand it, based on the estimated bandwidth, it selects the right track. But whenever I run it, it always selects the 600k bitrate track. And when I was trying to print the estimated bandwidth with getBitrateEstimate(), it always prints -1.

Is there anything wrong with it?

Uri uri = Uri.parse("https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd");

// bandwidthmeter is used for getting default bandwidth
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

// track selector is used to navigate between video using a default seekbar.
TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
// we are adding our track selector to exoplayer.
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);

// we are creating a variable for datasource factory and setting its user agent as 'exoplayer_view'
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("exoplayer_video");

DashMediaSource dashMediaSource = new DashMediaSource(uri, dataSourceFactory,
        new DefaultDashChunkSource.Factory(dataSourceFactory), null, null);

// inside our exoplayer view we are setting our player
exoPlayerView.setPlayer(exoPlayer);

// we are preparing our exoplayer with media source.
exoPlayer.prepare(dashMediaSource);
Log.i("BW", "BW: " + bandwidthMeter.getBitrateEstimate());
// we are setting our exoplayer when it is ready.
exoPlayer.setPlayWhenReady(true);

Upvotes: 1

Views: 702

Answers (0)

Related Questions