July 14, 2014

Multimedia - Playing Audio

Audio manager is used to play sounds in an activity. Different ways of using the audiomanager is shown below,


Following are the steps to play sound effects.
1. Get reference to the AudioManager
mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE)
2. Create a SoundPool
    mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
3. Load the sound
mSoundId = mSoundPool.load(this, R.raw.slow_whoop_bubble_pop, 1);
4. Housekeeping for soundmanager
5. Play the sound
mSoundPool.play(mSoundId, leftVolume, rightVolume, priority, loop, rate);

No comments:

Post a Comment