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. Silicon Valley Free Code Camp Nov 8-9

For those interested, Code Camp soon.  I see nothing Android-specific in the
115 sessions, but do see 36 Java-related sessions.

http://www.siliconvalley-codecamp.com/

easan



-- 
http://www.easankatir.com/

--~--~---------~--~----~------------~-------~--~----~

2. Does Android already support Multi-Touch??

Hi guys,

If some manufacturer builds a multi-touch device will Android handles
the inputs? Is that already implemented into Androids core?

Cheers


--~--~---------~--~----~------------~-------~--~----~

3. i am so beginner

4. MapView and SDK 1.0

5. D-Pad on the emulator does not exist on G1

6. Regarding view onKeyDown issue...

7. 20081024 What is the lastest on Android Speech Recognition ?