需要检查以下几个方面:
示例代码:
示例代码:
//初始化播放器
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(context);
//设置播放器的播放源
Uri videoUri = Uri.parse("https://sample.com/sample.mp4");
MediaSource mediaSource = new ExtractorMediaSource.Factory(new DefaultHttpDataSourceFactory("ExoPlayerDemo")).createMediaSource(videoUri);
player.prepare(mediaSource);
//创建播放器的控制器
SimpleExoPlayerView playerView = findViewById(R.id.player_view);
playerView.setPlayer(player);
player.setPlayWhenReady(true);
示例代码:
@Override
protected void onDestroy() {
super.onDestroy();
//释放播放器资源
if (player != null) {
player.release();
}
}