MediaPlayer blocked(AudioFlinger write blocked) while playing animation

by quill » Fri, 20 May 2011 15:19:15 GMT


Sponsored Links
 Hi all,

I have a thread to play audio and animation together. It's a frame
animation. The drawable resources are in sdcard. When I play the
animation, I use a handler to send message to refresh images one by
one.
Here's my code:
final Handler handle = new Handler(){
     public void handleMessage(Message msg){
          super.handleMessage(msg);
          BitmapDrawable bmpDraw = new BitmapDrawable("sdcard/
anim/"+msg.obj);
          imageView.setBackgroundDrawable(bmpDraw);
          imageView.invalidate();
          if(msg.what < fileNames.length-1){
              sendMessageDelayed(obtainMessage((msg.what+1),
fileNames[msg.what+1]),50);
         }
     }
};
handler.sendMessage(handler.obtainMessage(0,fileNames[0]);
MediaPlayer mp = new MediaPlayer();
...//play audio

The animation performs fine, but the audio will be stopped when it
begins to play for seconds. From logcat I see AudioFlinger: write
blocked for 89 msec...

I don't use AnimationDrawable because there are many images in sdcard,
when I use addFrame(AnimationDrawable.createFromPath(...)) I got an
OutOfMemory Exception.

Am I doing the right thing? Can anyone help me?

-- 



Other Threads

1. detect usb connected/disconnected event

Hi all!

 I had read in a lot of forum it is a problem to developers to write a
program witch can detect the connected / disconnected USB event. Here is my
solution:

Manifest.xml :

        <receiver android:name=".MyReceiver">
            <intent-filter>
                <action android:name="android.intent.action.ums_connected"
/>
            </intent-filter>
        </receiver>

Myreceiver:

public class MyReceiver extends BroadcastReceiver{
if (intent.getAction().equalsIgnoreCase(
        "android.intent.action.UMS_CONNECTED")) {...}
}


bye:Kroly Holczhauser from Hungary

-- 

2. How to investigate the memory leak in jni method?

Hi,

I found the investigation of jni memory leak is too hard to execute.

Anybody can give some clues for such problem??

Thanks.

-- 

3. Tanya A50/A10

4. how create a video with byte array

5. App is published in Android Market but not visible in some phones

6. best way to save images files

7. Two functions Button?