在播放 ConcatenatingMediaSource
播放列表中的视频时,我希望播放器在新项目开始时自动暂停,例如 . 不会自动播放 .
使用演示应用程序,我修改了 onPositionDiscontinuity
函数来检测当前项目更改:
int currentPosition = 0;
@Override
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
if (inErrorState) {
// This will only occur if the user has performed a seek whilst in the error state. Update
// the resume position so that if the user then retries, playback will resume from the
// position to which they seeked.
updateResumePosition();
}
if (player.getCurrentWindowIndex() != currentPosition) {
currentPosition = player.getCurrentWindowIndex();
player.setPlayWhenReady(false);
}
}
虽然此代码暂停播放器,但它不会清除播放器使用的表面视图,因此我们仍然可以看到上一个视频的最后一帧 . 我想这个回调过早被调用,但这是我发现的唯一回调,总是在播放列表项目更改时调用(可能不会调用 onPlayerStateChanged
) .
How can I have the first frame of the newly current item displayed instead of the previous item last frame?
我的弱解决方法是使用 Handler().postDelayed({ mPlayer?.playWhenReady = false }, 200)
延迟200ms的调用 .
1 回答
This is not supported yet: