package com.fusi24.entryPermitScanner.util;

import android.content.Context;
import android.media.AudioAttributes;
import android.media.SoundPool;

public class SoundUtil {

  protected static int soundid;
  protected static SoundPool soundpool = null;
  protected static AudioAttributes attributes = null;

  public static void initSound(Context context, Integer soundId){
    attributes = new AudioAttributes.Builder()
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
            .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
            .build();

    soundpool = new SoundPool.Builder()
            .setMaxStreams(1)
            .setAudioAttributes(attributes)
            .build();
    soundid = soundpool.load(context, soundId, 1);
  }

  public static void playSound(){
    soundpool.play(soundid, 1, 1, 0, 0, 1);
  }
}
