VideoView Disappears for a second when video is changed

自作多情 提交于 2019-12-12 19:35:58

问题


In my application there are some buttons on top of the screen and a video view under that.

In the oncreate event I start playing a mainvideo.mp4 in the VideoView and set it for looping.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.main);
    VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
    videoView.setVideoURI("android.resource://"+getPackageName() + "/"+R.raw.mainvideo);
    videoView.requestFocus();
    videoView.start();
} 

If the user clicks any of the buttons I want to change the video played by the VideoView to to buttonvideo.mp4. Below is the button onclick event code

Uri uri = Uri.parse("android.resource://"+getPackageName() + "/"+R.raw.buttonvideo);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();

When I tried using android 2.2 phone, once the button is clicked , the videoview disappears for a second and then plays the new video. I want the transition from one video to another as smooth as possible.

I tried this in another phone with android 4.0+ and this works flawlessly.Have seen some other applications do this, so there should be some way may be by overriding some event or custom videoview.Any idea?

来源:https://stackoverflow.com/questions/9660440/videoview-disappears-for-a-second-when-video-is-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!