31

I have an application with a VideoView in it, I set a video to play in the VideoView. At some point while the video is playing it will get paused. Then after it is paused for some time it will begin to play the video again, but seek forward to the point that the video would be at if it had not been paused. So for instance

Video starts playing

Video paused at 6 seconds

video stays paused for 10 seconds

Video starts playing again <--- at this point I want the video to start playing at the 16 second mark.

In order to achieve this effect I have set up time stamps to do the required math so I know how long the video was paused for, and then when I start it up again, I call mVideoView.seekTo(timePlayed + timePaused);

This all works as intended on Toshiba Thrive, and Motorola Xoom. However on Acer Iconia A200 It seems that from the point that I call seekTo() forward the VideoView will always return the same time when I call getCurrentPosition(). To illustrate this I set up a runnable that fires roughly every 1000ms that logs the current position. Here is some of the output from that:

/****************
* These are from before it is paused/resumed
* you can see that the current time is functioning
* as expected.
******************/
Current Position = 0
Current Position = 734
Current Position = 1735
Current Position = 2703
Current Position = 3737
Current Position = 4738
Current Position = 5739
Current Position = 6740
Current Position = 7741
Current Position = 8742
Current Position = 9743


/**********************************
* These are from the exact same runnable
* after the video has been paused, and
* started again after seekTo().
* The position is no longer increasing.
* Note that the video is playing correctly on the screen
* while these logs happen.
**********************************/
Current Position = 23410
Current Position = 23410
Current Position = 23410
Current Position = 23410

23410 is the exact time that I am passing in to seekTo(), so it seems that after I make this call the VideoView will always return whatever I pass in to it, no matter if it is actually still playing and the position is advancing.

Has anyone else experienced this VideoView/MediaPlayer bug before? I saw some things on the known issues group that were talking about MediaPlayer returning incorrect values for getCurrentPosition(), but didn't find any where it would just stop increasing like this. Most of the ones that I did see, were also trying to play audio rather than video.

Jonik
  • 80,077
  • 70
  • 264
  • 372
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • Do you use resume() to continue after pause()? resume not works on my Iconia A501. getCurrentPosition() returns value passed to seek but video still paused. – asktomsk Mar 28 '12 at 17:44
  • 1
    Can you send an example of the code? I'll check on my tablet. – asktomsk Mar 28 '12 at 17:52
  • 1
    I haven't seen the same problem as you but I have seen getCurrentPosition act unreliably - sometimes it returns 0 for me when the seek position is not 0. – MaximumGoat May 23 '12 at 20:46
  • on the Acer Iconia A200 or a different device? – FoamyGuy May 23 '12 at 21:30

3 Answers3

1

It may have to do with the amount of free memory of the device. if the ram is low the background activity may restart along with your counter.

SashiOno
  • 184
  • 2
  • 7
  • if the activity were restarting then the video on the screen would also restart. But the Video continues playing normally, and none of my Activity Lifecycle methods are being called so I suspect this is not the case. – FoamyGuy Jul 05 '12 at 21:47
1

release and reset the videoplayer in onpause method of activity and set again in onstart mtd of an activity.for seekto u must use chronometer to contain timing of user videoview.set timing in seekto to the chronometer time.

Sharad Mhaske
  • 1,103
  • 9
  • 19
1

Maybe it is a problem with overloading the main UI thread. Since video is a high data element and the acer iconia not being a great device, it could cause some data shortage, abnormalities and possibly even crashing. Try adding the video using AsyncTask.

Dylan Vander Berg
  • 1,809
  • 1
  • 22
  • 37