gpt4 book ai didi

android - Acer Iconia A200 上的 VideoView getCurrentPosition() 异常

转载 作者:IT老高 更新时间:2023-10-28 21:49:36 25 4
gpt4 key购买 nike

我有一个包含 VideoView 的应用程序,我设置了要在 VideoView 中播放的视频。在播放视频的某个时候,它会暂停。然后在暂停一段时间后,它会再次开始播放视频,但会向前搜索到视频未暂停时所在的位置。比如

视频开始播放

视频在 6 秒处暂停

视频暂停 10 秒

视频再次开始播放<---此时我希望视频在 16 秒标记处开始播放。

为了达到这个效果,我设置了时间戳来进行所需的数学运算,这样我就知道视频暂停了多长时间,然后当我再次启动它时,我调用 mVideoView.seekTo(timePlayed + timePaused);

这一切都可以在 Toshiba Thrive 和 Motorola Xoom 上正常运行。但是在 Acer Iconia A200 上,似乎从我调用 seekTo() 的角度来看,当我调用 getCurrentPosition() 时,VideoView 总是会同时返回。为了说明这一点,我设置了一个 runnable,它大约每 1000 毫秒触发一次,记录当前位置。以下是其中的一些输出:

/****************
* 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 是我传递给 seekTo() 的确切时间,所以似乎在我进行此调用后,VideoView 将始终返回我传递给它的任何内容,无论它实际上是否仍在播放以及位置正在推进中。

以前有没有其他人遇到过这个 VideoView/MediaPlayer 错误?我在已知问题组上看到了一些关于 MediaPlayer 为 getCurrentPosition() 返回错误值的内容,但没有找到任何会停止像这样增加的地方。我看到的大多数人也在尝试播放音频而不是视频。

最佳答案

这可能与设备的可用内存量有关。如果内存不足,则后台 Activity 可能会与您的计数器一起重新启动。

关于android - Acer Iconia A200 上的 VideoView getCurrentPosition() 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9437304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com