var isMuted = false
var isBgMenuMusicPlaying = false;

function loadAudio() {
    Crafty.audio.add({
             
              BgmMenu: [
              "audio/Solitaire - menu tune (mastered).ogg",
              ],

              GameMusic: [
              "audio/Solitaire -game tune (mastered).ogg",
              ],

              ButttonClick: [
              "audio/General Button Click.ogg",
              ],

              GameWin: [
              "audio/Solitaire - Game Win.ogg",
              ],
            });
    console.log("AAAUUUUUUUDDDDDDDDDDDIIIIIIIIIIIOOOOOOOOOOO LOADED")
}

function setAudioIsMuted(pBool) {
    // console.log("set the audio to ", pBool)
    isMuted = pBool
}

			
function getAudioIsMuted() {
    // console.log(" returning get audio is muted function with ", isMuted)
    return isMuted
}

			
//the following function will convert all floating point numbers to integers example 3.99 to 3
function playSfxAudio(pAudioName) {
    // console.log("float to int", value|0)
   
    if(isMuted) {  return true; }
    if(pAudioName==undefined) return true;
    Crafty.audio.play(pAudioName)
    // console.log("audio muted ", isMuted)
			
}

			
function playBgMusic(pAudioName) {
    console.log("play bg music ", isMuted, pAudioName, isBgMenuMusicPlaying)
    if(isMuted) {
		return true;
	}
    if(pAudioName==undefined) return true;
    if(pAudioName=="BgmMenu" ) { 
        if(isBgMenuMusicPlaying) {
			return true ; 
		} 
		else { 
            console.log("bg menu setted to true now");
			isBgMenuMusicPlaying=true;
		}
    }
    Crafty.audio.stop();
    Crafty.audio.play(pAudioName, -1)
}
			

function setBgMusicPlaying() {
    isBgMenuMusicPlaying=false;
}

