Why doesn't MediaPlayer.seekTo(t) go to the exact specified instant “t”?

痴心易碎 提交于 2020-01-24 08:26:01

问题


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.

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.

This is the code:

mediaPlayer.start();
mediaPlayer.seekTo(time);

Is this normal? Or am I using the media player the wrong way?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/25656102/why-doesnt-mediaplayer-seektot-go-to-the-exact-specified-instant-t

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