我正在使用Videoview播放音频。如果在播放器处于暂停状态时尝试更改方向,则播放器将失去此状态并继续播放。
我试图阻止它但没有成功。
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("pos", mediaView.getCurrentPosition());
outState.putBoolean("playerState", mediaView.isPlaying());
}
并在恢复时
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
boolean playerState = savedInstanceState.getBoolean("playerState");
if(playerState) {
mediaView.start();
} else {
this.posOfMedia = mediaView.getCurrentPosition();
mediaView.pause();
}
}
有人知道如何在旋转后保持暂停状态