开发者

MP3Extractor(34): Unable to resync. Signalling end of stream

I am getting error when trying to play mp**3 file from my **resource folder in Android application

i have created raw folder in res folder this is sample code through which i am playing

MediaPlayer mediaPlayer = MediaPlayer.create(getBaseContext(), R.raw.b);
mediaPlayer.start();

LOG :

09-02 10:44:07.854: INFO/AndroidRuntime(441): NOTE: attach of thread 'Binder Thread #3' failed
09-02 10:44:08.003: DEBUG/AudioSink(34): bufferCount (4) is too small and increased to 12
09-02 10:44:08.224: WARN/AudioFlinger(34): write blocked for 117 msecs, 44 delayed writes, thread 0xb3f0
09-02 10:44:08.283: INFO/ActivityManager(59): Displayed activity com.soundtest/.SoundTestActivity: 511 ms (total 511 ms)
09-02 10:44:13.052: ERROR/MP3Extractor(34): Unable to 开发者_运维问答resync. Signalling end of stream.

i am missing something or what??


The error went away after I decided to copy mp3 files from assets to SD. It is working fine when my data source is set with uri of SD storage rather than assets.


can you try:

AssetFileDescriptor afd = ctx.getResources().openRawResourceFd(params[0]);

try
{   
    //final MediaPlayer mediaPlayer = new MediaPlayer();
    mediaPlayer.reset();
    mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
    mediaPlayer.prepare();
    mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
        public void onPrepared(MediaPlayer arg0) {
            mediaPlayer.seekTo(0);
            mediaPlayer.start();
        });
    }
});
afd.close();


convert mp3 to ogg, and the error will vanish. i have tested two files. ogg doesn't play as smooth as mp3 but there is nothing error showed in log.


hey, after i test the warning like this: WARN/AudioFlinger(33): write blocked for 76 msecs, 7773 delayed writes, thread 0xb3f0

i test the mp3 file again, and the error dosen't show up.

i believe it is the permission losing that trigger the error, not the file format.

in my understanding, prepare() would make a image of the music file so the player can play again and again, synchronously. but if we didn't set the permission, write blocked, and the read(play again) and write become not synchronous. so it is 'Unable to resync'.

but i don't understand why it write again and again at every time the music replay. do i misunderstand?

en, as to the ogg file, i don't know why it could avoid error either.

but never mind, i do believe i have gotten the correct answer. it is add these permission:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜