0

this is my code

using System;
using WMPLib;
namespace MediaPlayerRepate {
    public class AAA {

        public static WindowsMediaPlayer wmp = new WindowsMediaPlayer();
        public static string FileAddress1 = @"C:\Users\MySystem\Downloads\A.mp3";
        public static string FileAddress2 = @"C:\Users\MySystem\Downloads\B.mp3";

        public static void Main(string[] args) {
            wmp.PlayStateChange += Wmp_PlayStateChange;
            IWMPMedia MyMedia = wmp.newMedia(FileAddress1);
            wmp.currentMedia = MyMedia;
            wmp.controls.play();

            Console.ReadLine();
        }

        private static void Wmp_PlayStateChange(int NewState) {
            if ((WMPPlayState)NewState == WMPPlayState.wmppsMediaEnded) {
                // The audio file has ended, so repeat it
                IWMPMedia media = wmp.newMedia(FileAddress2);
                wmp.currentMedia = media;
                wmp.controls.play();
            }
        }
    }
}

originally I want to use this code to play a single mp3 file in loop or use this event to play the next audio on my list when a file reach to its end

and I know about the setMode("loop",true) function

so the question is why this code wont play the FileAddress2 ????

I did put a break point inside the Wmp_PlayStateChange all i can say it dose hit the breakpoint but not playing the audio

  • 1
    Did you verify what state (or states) the player goes through when playing and finishing `FileAddress1`? In [this example from microsoft](https://learn.microsoft.com/en-us/windows/win32/wmp/creating-the-windows-media-player-control-programmatically) the state `wmppsStopped` is used instead. – KompjoeFriek Apr 26 '23 at 00:09

0 Answers0