VideoView getCurrentPosition() irregularity on Acer Iconia A200

不打扰是莪最后的温柔 提交于 2021-02-07 11:16:57

问题


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.


回答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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9437304/videoview-getcurrentposition-irregularity-on-acer-iconia-a200

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