On Sat, Jun 27, 2009 at 1:08 PM, Baratong<pwalter...@gmail.com> wrote:
>
>
> I've found the audio subsystem is a little quirky. It's great if you
> are playing songs, or video but if you are writing a game that plays
> short sounds quickly it poses problems. After much work I found a
> pretty cool solution to one of the annoying problems of MediaPlayer
> being sluggish to play audio.
>
> The problem is the audio system tends to go to sleep after 3 seconds.
> When my application tries to play the next sound the phone's audio
> system wakes up but seems to queue the sound instead of playing it.
> When my application plays yet another sound -- as long as the sound
> system hasn't gone back to sleep again -- it plays BOTH sounds at
> once! This causes unacceptable behavior for any game.
>
> What I ended up doing was this:
> 1. Use Audacity to create a 1-second .wav of total silence and add the
> wave into my manifest as a raw resource referenced in the app as
> R.raw.silence.
> 2. On startup, create a MediaPlayer instance, load the R.raw.silence
> resource and play in a loop constantly.
>
> This worked great at keeping the audio system awake, however the phone
> was now draining the battery quickly whenever the game was loaded.
> Since Android (and most phones) don't have a great way for the user to
> terminate a task, this meant if you played the game for a couple of
> minutes in the morning, the battery would drain at an accelerated rate
> for the rest of the day! A bit unacceptable.

Indeed. It is unacceptable for an application to not clean up after
itself. Why did you not simply stop the sound in your application's
onPause() ?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to