播放器在播放在线视频时会消耗太多数据
我正在制作一个从URL播放视频的应用程序。我正在使用埃法赛车,但是我注意到,当我在范围内播放在线视频时,它会消耗太多数据。例如,当我播放电影URL时,它只会加载2-3秒,而我的系列仪会消耗大约400MB,而我不确定为什么。
这是我的视频播放方法。我做错了吗?
private void playvideo() {
String MOVIEURL = getIntent().getStringExtra("playthis");
Uri uri = Uri.parse(MOVIEURL);
player = new SimpleExoPlayer.Builder(this).setSeekForwardIncrementMs(10000).setSeekBackIncrementMs(10000).build();
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(
this, Util.getUserAgent(this , "app"));
concatenatingMediaSource = new ConcatenatingMediaSource();
// app:rewind_increment="1e000"
// app:fastforward_increment="10000"
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(Uri.parse(String.valueOf(uri))));
concatenatingMediaSource.addMediaSource(mediaSource);
playerView.setPlayer(player);
playerView.setKeepScreenOn(true);
player.prepare(concatenatingMediaSource);
player.seekTo(position , C.TIME_UNSET);
playError();
}
private void playError() {
player.addListener(new Player.Listener() {
@Override
public void onPlayerError(PlaybackException error) {
Toast.makeText(video_player.this, "Error", Toast.LENGTH_SHORT).show();
}
});
I'm making an app which plays videos from a URL. I'm using Exoplayer, but I noticed that when I play an online video in Exoplayer, it consumes too much data. For example, when I play a movie URL, it just loads for 2-3 seconds and my Exoplayer consumes around 400mb, and I'm not sure why.
This my video playing method in Exoplayer. Is there something I did wrong?
private void playvideo() {
String MOVIEURL = getIntent().getStringExtra("playthis");
Uri uri = Uri.parse(MOVIEURL);
player = new SimpleExoPlayer.Builder(this).setSeekForwardIncrementMs(10000).setSeekBackIncrementMs(10000).build();
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(
this, Util.getUserAgent(this , "app"));
concatenatingMediaSource = new ConcatenatingMediaSource();
// app:rewind_increment="1e000"
// app:fastforward_increment="10000"
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(Uri.parse(String.valueOf(uri))));
concatenatingMediaSource.addMediaSource(mediaSource);
playerView.setPlayer(player);
playerView.setKeepScreenOn(true);
player.prepare(concatenatingMediaSource);
player.seekTo(position , C.TIME_UNSET);
playError();
}
private void playError() {
player.addListener(new Player.Listener() {
@Override
public void onPlayerError(PlaybackException error) {
Toast.makeText(video_player.this, "Error", Toast.LENGTH_SHORT).show();
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论