Android 视频重新启动并带有方向
如何在方向改变时避免重新加载视频,即强制视频从同一方向恢复。
我在下面尝试过,但失败了
vd = (VideoView) findViewById(R.id.vplayer);
.......
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("Position",vd.getCurrentPosition());
}
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int position= savedInstanceState.getInt("Position");
vd.seekTo(position);
}
How to avoid reloading of video with orientation change i.e force the video to resume from same.
i have tried below but it fails
vd = (VideoView) findViewById(R.id.vplayer);
.......
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("Position",vd.getCurrentPosition());
}
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int position= savedInstanceState.getInt("Position");
vd.seekTo(position);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做的就是在方向改变时停止重新创建您的 Activity。您可以通过在
activity 标记
中添加AndroidManifest.xml
文件来实现此目的What you can do is stop your Activity to get re-created when orientation changes. You can do that by adding in your
AndroidManifest.xml
file in theactivity tag