MediaPlayer.seekTo()不无缓冲的位置工作 [英] MediaPlayer.seekTo() does not work for unbuffered position
问题描述
我用的MediaPlayer从网络打单首MP3歌曲。数据源是一个HTTP URL。
I use MediaPlayer for playing a single mp3 song from network. Data source is a HTTP URL.
让我们假设有下面的播放状态。
Let's assume we have following playing state.
宋时间:1:00
进展情况:0:10
当前缓冲进度0:30
Current buffering progress 0:30
比方说,我想跳过一首歌的某一部分,并寻求前进。我做它MediaPlayer.seekTo()方法。如果我试图缓冲的位置(0:20),它被正确执行。但是,如果我努力还没有被缓冲,但(0:40)的位置上的MediaPlayer的行为古怪。它立即指示它已正确seeked而不等待一个缓冲器来填补。事实上,它继续播放在它是寻求前相同的位置。从现在开始MediaPlayer.getCurrentPosition()方法返回错误的位置。当播放到达终点,并OnCompletionListener.onCompletion回调被称为当前媒体播放器的位置是不是整首歌曲的持续时间要高得多。
Let's say I want to skip some part of a song and seek forward. I do it with MediaPlayer.seekTo() method. If I seek to buffered position (0:20) it is performed correctly. But if I seek to a position which has not been buffered yet (0:40) the MediaPlayer behaves odd. It indicates immediately that it has seeked correctly without waiting for a buffer to fill. In fact it continues playing at the same position where it was before seeking. From now on MediaPlayer.getCurrentPosition() method returns wrong position. When playing reaches its end and OnCompletionListener.onCompletion callback is called the current media player position is much higher than entire song duration.
任何想法解决这个?
推荐答案
它可能与多数民众赞成(指评论之一)的错误,最终定格在2.2 HTTP://$c$c.google.com/p /安卓/问题/详细信息?ID = 4124
It's probably related to the bug that's (referring to one of the comments) eventually fixed in 2.2 http://code.google.com/p/android/issues/detail?id=4124
这篇关于MediaPlayer.seekTo()不无缓冲的位置工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!