Problem with videoView on Android

I had a problem using 2 VideoViews on Android.

I know that I can't use 2 VideoViews at the same time.

Here is my workflow.

  • Create 2 videoViews.
  • Hide 1 of them.
  • Prefetch the first videoView.
  • Play the first VideoView.
  • In a different thread I prefetch the second video
  • In some point I switch the videoViews.
  • The second Video is working fine.
  • When the second video is completed then I switch to the first video.
  • The video starts playing from beginning instead of the last state of the first video.
  • I tried to get the current time and save it before the switch and then when the first video view comes back then I use seekTo(LastCurrenttime), but the buffer is gone (before last currentTime).

    do you know if the buffer is static or if the videoViews use only one buffer?

    Why does the videoView not save the last state of the videView? ((currentTime or the buffer state?

    Is there a way to do this without doing the seekTo function?


    My theory is that because the first VideoView is being hidden this means suspend() and resume() are being called on the view. If you search for 'suspend' and 'resume' in the source code for VideoView, you can see that the MediaPlayer instance is released and reallocated.

    My suggestion is that you create a customized VideoView that modifies this behavior.

    I show how to customize VideoView in my answer to 7990784.

    Using that as a starting point, you could rewrite the resume() function to avoid the call to openVideo().

    链接地址: http://www.djcxy.com/p/46488.html

    上一篇: Android如何更改默认的VideoView / MediaPlayer全屏?

    下一篇: Android上的videoView问题