我正在Android上使用ExoPlayer播放视频。但是“DefaultBandwidthMeter();“已弃用。
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
//DefaultTrackSelector chooses tracks in the media item
DefaultTrackSelector trackSelector = new DefaultTrackSelector(this);
trackSelector.setParameters(trackSelector.buildUponParameters().setMaxVideoSizeSd());
mPlayer = new SimpleExoPlayer.Builder(this).setTrackSelector(trackSelector).build();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayerapp"), bandwidthMeter);
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url));
mPlayer.prepare(mediaSource);
playerView.setKeepScreenOn(true);
playerView.requestFocus();
playerView.setPlayer(mPlayer);
mPlayer.setPlayWhenReady(true);
playBackStateListener = new PlayBackStateListener();
mPlayer.addListener(playBackStateListener);
我应该用什么代替这个,根据这个,我应该用什么来替换下面使用带宽计的行?
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayerapp"), bandwidthMeter);
2条答案
按热度按时间0yg35tkg1#
您应该使用ExoPlayer文档中的DefaultBandwidthMeter.Builder . Source。
lg40wkob2#
如果您使用
HLS
介质类型,您应该:注意:它工作这个版本:
implementation 'com.google.android.exoplayer:exoplayer:2.18.2'