public final class SoundEffect

  1. Object
  2. SoundEffect

A short, reusable sound clip loaded into a SoundPool.

Obtain one with SoundPool#load(String) or SoundPool#load(java.io.InputStream, String), then play it any number of times – overlapping plays mix together up to the pool’s voice limit. A sound effect belongs to the pool that created it and must not be used with a different pool.

Methods

public SoundPool getPool()The pool that owns this effect.
public boolean isLoaded()True until #unload() is called.
public int play()Plays the effect once at full volume, returning a voice id or -1 if the pool is exhausted.
public int play(float volume, float pan, float rate, int loop)Plays the effect with explicit parameters.
public void unload()Releases this effect’s buffers from the pool.

Inherited methods

Method details

getPool

public SoundPool getPool()
The pool that owns this effect.

isLoaded

public boolean isLoaded()
True until #unload() is called.

play

public int play()
Plays the effect once at full volume, returning a voice id or -1 if the pool is exhausted. Equivalent to pool.play(this).

play

public int play(float volume, float pan, float rate, int loop)
Plays the effect with explicit parameters. See SoundPool#play(SoundEffect, float, float, float, int).

unload

public void unload()
Releases this effect’s buffers from the pool. The effect must not be played afterwards.