我正在尝试播放视频的exo播放器,但它给我这个错误:-
E/外部播放器实施内部:来源错误。
无效响应代码异常:响应代码:404
这是我的活动类:-
public class VideoActivity extends AppCompatActivity implements VideoRendererEventListener {
private String mVideoUrl;
private SimpleExoPlayerView simpleExoPlayerView;
private SimpleExoPlayer player;
private static final String TAG = "AMAN";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
if (getIntent() != null)
mVideoUrl = getIntent().getStringExtra("VideoUrl");
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
simpleExoPlayerView = new SimpleExoPlayerView(this);
simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
simpleExoPlayerView.setUseController(true);
simpleExoPlayerView.requestFocus();
simpleExoPlayerView.setPlayer(player);
Uri mp4VideoUri =Uri.parse(mVideoUrl);
DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayer2example"), bandwidthMeterA);
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource videoSource = new HlsMediaSource(mp4VideoUri, dataSourceFactory, 1, null, null);
final LoopingMediaSource loopingSource = new LoopingMediaSource(videoSource);
player.prepare(loopingSource);
player.setPlayWhenReady(true);
}
有人知道这里出了什么问题吗?
1条答案
按热度按时间krcsximq1#
您必须为链接使用“final”修饰符。