问题
I'm getting an AAC stream from a HTTP server and using that as the datasource for the MediaPlayer
in Android.
It plays perfectly fine, but when I try to execute mediaPlayer.seekTo(int position)
I get the following errors about a million times:WARN/AACDecoder(13889): AAC decoder returned error -1, substituting silence
WARN/AACDecoder(13889): AAC decoder returned error 10, substituting silence
WARN/AACDecoder(13889): AAC decoder returned error 1, substituting silence
This error happens on Android 2.2 but it does not seem to work on earlier versions either. Support for seeking is a must in my application, and I would like it to work for Android 1.5 - 2.2.
Is there any good solution on how to seek in AAC streams?
回答1:
You cannot seek a served stream. How could the server handle this?
Even if you save the bytes, raw AAC streams are non-seekable (they contain no seek information). Some media players get around this by parsing the whole file and indexing it on the fly every time they load it. A better solution is to repackage the stream into a container, like MP4. Here's an example using MP4Box:
MP4Box -add raw_stream.aac -new output_file.mp4
来源:https://stackoverflow.com/questions/3933387/seeking-in-aac-streams-on-android