【发布时间】:2012-09-22 17:36:49
【问题描述】:
我非常喜欢这个网站,因为我可以找到许多有用的解决方案,对我很有帮助,尤其是我是 android 编程的初学者,这是我的第一个问题,所以我希望能从这个伟大的社区中得到帮助。
问题: 我在我的应用程序中播放视频,并在用户定向屏幕时使其以横向全屏播放,所以我想通过使用 seekTo() 和 getCurrentPosition() 让视频从同一点重新开始播放 - 但是视频播放几秒钟后的问题我的意思是视频在同一时间点搜索的位置,但是当开始播放时它会增加很多秒。
我的代码:
//initialise everything
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
v = (VideoView) findViewById(R.id.videoView1);
v.setVideoPath(dir + videoName + ".3gp");
v.setMediaController(new MediaController(this));
if (savedInstanceState == null){
v.start();
}
else {
playingTime = savedInstanceState.getInt("restartTime", 0);
v.seekTo(playingTime);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
if (file.exists()){
playingTime = v.getCurrentPosition();
v.stopPlayback();
outState.putInt("restartTime", playingTime);
}
}
我尝试了很多这样的解决方案 How to keep playing video while changing to landscape mode android
我正在使用 Galaxy Nexus 测试我的应用程序。如果有任何提示,我将不胜感激。 对不起我的英语不好,非常感谢。
【问题讨论】:
标签: android landscape android-videoview