import { Injectable } from "@angular/core";

@Injectable({
  providedIn: "root",
})
export class AudioService {
  public playSound(sound: Sounds){
    let audio: HTMLAudioElement = new Audio(sound);
    audio.volume = this.getVolume();
    audio.play();
  }

  private getVolume(): number{
    let volume = localStorage.getItem("volume");
    if(volume){
      return parseFloat(volume);
    }
    else{
      return 1;
    }
  }
}

export enum Sounds{
  NOTIFICATION = "/assets/sounds/pop.mp3",
  BACKGROUND_NOTIFICATION = "/assets/sounds/back-pop.mp3"
}