Thursday, May 17, 2012

AudioManager – SoundPool in Android


he sound files played with SoundPool should not exceed 1 MB.SoundPool does load the file asynchronously.
Android supports different audio streams for different purposes. The phone volume button can be configured to control a specific audio stream, e.g. during a call the volume button allow increase / decrease the caller volume. To set the button to control the sound media stream set the audio type in your application.
context.setVolumeControlStream(AudioManager.STREAM_MUSIC);

As of Android API8 it is possible to check if the loading is complete via a OnLoadCompleteListener.
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
            @Override
            public void onLoadComplete(SoundPool soundPool, int sampleId,
                    int status) {
                loaded = true;
            }
        });

1 comment:

  1. Thanks for the extreamly useful post .
    To decide whether we should used SoundPool or MediaPlayer is also critical. SoundPool is preferred when soundstreams are very short and plentyful otherwise we prefer MediaPlayer.Here is another useful blog putting light on this issue.http://blog.creatiosoft.com/?p=1265

    ReplyDelete