Do ... While System.Media.SoundPlayer() is in use

283 Views Asked by At

I have been trying to display text on my Console Application while a sound file is currently playing, lyrics as an example. How is the best way to do it?

struct Music 
{
        public
            void PlaySong() {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = @"C:\Users\MyPC\Music\MoreMusic\songsample.wav";
            player.Load();
            player.PlaySync();
        }
}

class Program
{


        static public void Main(string[] args)
        {
            Music music;
            do
            {
                //Display Lyrics
            } while (true); //as the song progresses


         }

}
1

There are 1 best solutions below

0
On BEST ANSWER

Replace the PlaySync with Play

    struct Music 
{
        public
            void PlaySong() {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = @"C:\Users\MyPC\Music\MoreMusic\songsample.wav";
            player.Load();
            player.Play();
        }
}