开发者

AudioHardware pcm playback is going to standby error for playing from SD-card

After reading several similar questions I found that all developers that experience this error see this behaviour when streaming media files from the internet.

I use audio files (MP3) from the SD card and I play them in a Service. I do play them one after each other and at some point MediaPlayer dies with the message shown in the title. It does not throw any error thru the registered OnErrorListener. It's simply dead after the last tune of one of the files. It's always the same file if I use the same file order.

Tracing the app did not show any growth in memory consumption. I even tried to make MediaPlayer static to avoid GC. The las开发者_如何学Ct approach was to close MediaPlayer intirely, NULL its static variable and create and restart everything new. This didn't help. If the hardware is gone - it's gone.

I do experience this with a Google Nexus One and I need help. I read a tip to fade out three seconds before end of the files. Is this really a solution and how should I do this?

Many thanks in advance.


well, I think u implemented "onCompletion" event of MediaPlayer, I think the bug is that android fires onCompletion event while (mediaPlayer.isPlaying) still true so my idea is to stop media player before playing next mp3

something like this ...

public void onCompletion(MediaPlayer mp) {
                    if(mp != null && mp.isPlaying()){
            Log.d("onCompletion", "mp is playing !!! stop it!!!");
            mp.stop();
        }
        /*
        play next item here or prepare or ...
        */
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜