MediaPlayer.seekTo(t)为什么不转到确切的指定瞬间"t"? [英] Why doesn't MediaPlayer.seekTo(t) go to the exact specified instant "t"?
问题描述
我正在尝试让媒体播放器在本地存储的视频中播放特定范围.我似乎没有在指定的时间开始.
I'm trying to get the media player to play a specific range in a locally stored video. It doesn't seem to start at the specified time I tell it to.
示例:当我寻求1000时,它可以工作.但是当我寻求1500时,它将改为2000.
Example: when I seek to 1000, it works. But when I seek to 1500, it goes to 2000 instead.
我还尝试过暂停搜索,然后从搜索完成开始,这没有任何区别.
I also tried pausing seeking then starting on seek completion, it doesn't make any difference.
这是代码:
mediaPlayer.start();
mediaPlayer.seekTo(time);
这正常吗?还是我以错误的方式使用媒体播放器?
Is this normal? Or am I using the media player the wrong way?
推荐答案
这是一个编码问题.视频具有关键帧( i帧),该关键帧比其他帧存储更多的信息.仅在给定前一个关键帧的情况下才能构建非关键帧.尝试显示非关键帧将显示绿色斑点和像素化抖动屏幕.
This is an encoding issue. Videos have keyframes (i-frames) that store more information than other frames. A non keyframe can be built only given the previous keyframe. Trying to display a non keyframe will show green spots and pixelated jittery screen.
现在,在某些android设备上,尚未实现解决方法,因此您会遇到这种奇怪的行为.例如,在Nexus S上,seekTo()
不一定会转到指定的帧.我尝试了其他具有相同Android版本的设备,但它们查找得很好.
Now, on some android devices there's no workaround implemented for this so you get this weird behavior. On a Nexus S for example seekTo()
doesn't necessarily go to the specified frame. I tried other devices with the same android version and they seek just fine.
这篇关于MediaPlayer.seekTo(t)为什么不转到确切的指定瞬间"t"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!