恢复从onResume打VideoView [英] Resume playing VideoView from onResume
本文介绍了恢复从onResume打VideoView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个VideoView,这是当我开始电子邮件意图暂停。当电子邮件的意图做,我想videoView继续打球,但是,它从头重新开始。
I have a VideoView and it is pause when I start an Email intent. When the email intent is done, I want the videoView to continue playing, however, it restarts from the beginning.
@Override
public void onPause() {
Log.d(TAG, "onPause called");
super.onPause();
videoView.pause();
}
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume called");
videoView.start();//resume() doesnt work
}
我怎样才能获得videoView从停止的地方重新开始。
How can I get the videoView to resume from where it left off.
推荐答案
怎么样的:
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume called");
videoView.seekTo(stopPosition);
videoView.start(); //Or use resume() if it doesn't work. I'm not sure
}
// This gets called before onPause so pause video here.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
stopPosition = videoView.getCurrentPosition();
videoView.pause();
outState.putInt("position", stopPosition);
}
然后在您的onCreate()调用从包中stopPosition和全球范围内设置
Then in your onCreate() call the stopPosition from the bundle and set it globally
@Override
protected void onCreate(Bundle args) {
super.onCreate(args);
if( args != null ) {
stopPosition = args.getInt("position");
}
这篇关于恢复从onResume打VideoView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文