Sound


Interface :: Sound >> Sound.java

package toxin.schnee.framework;

public interface Sound
{
  public abstract void play(float volume);
  public abstract void dispose();
}

Concrete :: Sound >> SoundImpl.java

package toxin.schnee.framework.impl;

import android.media.SoundPool;
import toxin.schnee.framework.Sound;

public final class SoundImpl implements Sound
{
  private int soundId;
  private SoundPool soundPool;

  public SoundImpl(SoundPool soundPool, int soundId){
    this.soundId = soundId;
    this.soundPool = soundPool;
  }

  @Override
  public final void play(float volume){
    soundPool.play(soundId, volume, volume, 0, 0, 1);
  }
  @Override
  public final void dispose(){
    soundPool.unload(soundId);
  }
}

Remove all ads