我在RecyclerView中有一个Exoplayer。在活动中使用Exoplayer时,可以使用onPause和onResume停止/恢复播放器:
//pause player
@Override
protected void onPause() {
if(simpleExoPlayer != null) {
positionExo = simpleExoPlayer.getCurrentPosition();
simpleExoPlayer.setPlayWhenReady(false);
}
super.onPause();
}
//resume player
@Override
protected void onResume() {
super.onResume();
if(simpleExoPlayer != null) {
simpleExoPlayer.seekTo(positionExo);
simpleExoPlayer.setPlayWhenReady(true);
}
}
如何在适配器内执行此操作?