using Plugin.Maui.Audio;

namespace MusiLib.Views
{
    public interface IPlayMusic
    {
        static AudioPlayer player;
        static bool isMusicPlaying = false;
        static bool isMusicBeginning = false;

        public static async void beginMusic()
        {
            player = (AudioPlayer)AudioManager.Current.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("au_clair_de_la_lune.wav"));
            player.Play();
            isMusicPlaying = true;
            isMusicBeginning = true;
        }

        public static void playMusic()
        {
            player.Play();
            isMusicPlaying = true;
        }

        public static void pauseMusic() 
        { 
            player.Pause();
            isMusicPlaying = false;
        }

        public static void stopMusic()
        {
            if(isMusicBeginning)
            {
                player.Stop();
                isMusicPlaying = false;
                isMusicBeginning = false;
            }
        }

    }
}
