我正在根据媒体播放器更新seekbar。有时它会停下来更新进度,它会卡住,我得到的值是一样的。(但声音不会结巴)这是我的logcat消息,我打印出进度,你可以看到它一直运行到2048年,然后它停止,一段时间后它继续更新。为什么?(我注意到自从android 4.0之后,我的另一部android 2.2手机就没有这样的问题了)
01-28 16:41:21.446: D/MyMediaPlayer(10342): progress: 56 / 10472
01-28 16:41:21.501: D/MyMediaPlayer(10342): progress: 107 / 10472
01-28 16:41:21.556: D/MyMediaPlayer(10342): progress: 158 / 10472
01-28 16:41:21.610: D/MyMediaPlayer(10342): progress: 209 / 10472
01-28 16:41:21.657: D/MyMediaPlayer(10342): progress: 261 / 10472
01-28 16:41:21.704: D/MyMediaPlayer(10342): progress: 311 / 10472
01-28 16:41:21.759: D/MyMediaPlayer(10342): progress: 362 / 10472
01-28 16:41:21.806: D/MyMediaPlayer(10342): progress: 413 / 10472
01-28 16:41:21.837: D/dalvikvm(307): GC_CONCURRENT freed 1835K, 16% free 19932K/23495K, paused 3ms+12ms, total 101ms
01-28 16:41:21.860: D/MyMediaPlayer(10342): progress: 458 / 10472
01-28 16:41:21.907: D/MyMediaPlayer(10342): progress: 514 / 10472
01-28 16:41:21.962: D/MyMediaPlayer(10342): progress: 565 / 10472
01-28 16:41:22.009: D/MyMediaPlayer(10342): progress: 616 / 10472
01-28 16:41:22.063: D/MyMediaPlayer(10342): progress: 667 / 10472
01-28 16:41:22.118: D/MyMediaPlayer(10342): progress: 718 / 10472
01-28 16:41:22.165: D/MyMediaPlayer(10342): progress: 770 / 10472
01-28 16:41:22.212: D/MyMediaPlayer(10342): progress: 820 / 10472
01-28 16:41:22.267: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.313: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.368: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.415: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.470: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.524: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.571: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.626: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.673: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.727: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.774: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.829: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.884: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.931: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:22.985: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.032: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.087: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.142: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.188: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.243: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.290: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.345: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.392: D/MyMediaPlayer(10342): progress: 2048 / 10472
01-28 16:41:23.454: D/MyMediaPlayer(10342): progress: 2054 / 10472
01-28 16:41:23.501: D/MyMediaPlayer(10342): progress: 2105 / 10472
01-28 16:41:23.556: D/MyMediaPlayer(10342): progress: 2155 / 10472
01-28 16:41:23.602: D/MyMediaPlayer(10342): progress: 2207 / 10472
01-28 16:41:23.657: D/MyMediaPlayer(10342): progress: 2258 / 10472
01-28 16:41:23.712: D/MyMediaPlayer(10342): progress: 2309 / 10472
01-28 16:41:23.751: D/MyMediaPlayer(10342): progress: 2360 / 10472
01-28 16:41:23.813: D/MyMediaPlayer(10342): progress: 2411 / 10472
最佳答案
我曾经注意到一个类似的问题getCurrentPosition()
没有返回正确的值。
请看这里:VideoView getCurrentPosition() irregularity on Acer Iconia A200
我从未发现是什么导致它返回错误的位置。然而,我所采用的解决方法只是通过存储开始视频的时间戳并参考该时间戳来确定视频播放的时间,从而自己跟踪时间。似乎是多余的,但这至少给了我正确的值,当内置方法没有。