我正在开发一个Android应用程序,它有一个exoplayer活动,播放hls媒体。我面临一个对我来说很奇怪的问题。当被称为启动器活动时,玩家活动运行良好,但是当我从其他活动中调用它时,它会在12秒后立即停止缓冲。检查日志猫给了我错误,这与播放列表有关。下面是我的exoplayer活动示例代码。如果将此活动称为启动器主活动,则它运行绝对正常。作为启动器运行活动和从其他意图启动活动之间有什么区别吗?请帮我解决这个问题。我的日志猫错误:
E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$PlaylistStuckException
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$MediaPlaylistBundle.processLoadedPlaylist(HlsPlaylistTracker.java:598)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$MediaPlaylistBundle.onLoadCompleted(HlsPlaylistTracker.java:539)
at com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistTracker$MediaPlaylistBundle.onLoadCompleted(HlsPlaylistTracker.java:472)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.handleMessage(Loader.java:383)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Exoplayer活动:
private void initializePlayer() {
final SimpleExoPlayerView simpleExoPlayerVoiw;
Uri mp4VideoUri;
DefaultBandwidthMeter 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);
simpleExoPlayerVoiw = (SimpleExoPlayerView) findViewById(R.id.player_view);
/* player.release();
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);*/
simpleExoPlayerVoiw.setUseController(true);
simpleExoPlayerVoiw.requestFocus();
simpleExoPlayerVoiw.setPlayer(player);
mp4VideoUri = Uri.parse("http://125.17.129.4/wh7f454c46tw2717373403_526904823/PLTV/88888888/224/3221225827/01.m3u8"); //Radnom 540p indian channel
DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "cricflame"),(TransferListener<? super DataSource>) bandwidthMeterA);
MediaSource mediaSource = new HlsMediaSource(mp4VideoUri, dataSourceFactory, 1, null, null);
final LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource);
player.prepare(loopingMediaSource);
player.setPlayWhenReady(true);
}
@Override
protected void onDestroy() {
super.onDestroy();
player.release();
}
@Override
protected void onStart() {
super.onStart();
initializePlayer();
}