自动循环播放 播放器

 来到一家新公司,到了下午的时候,我放松一下,

闲聊的时候说要写一到下午三点就放松一下,

放点歌曲来听听,

我就来写这个程序了!

程序下载地址

http://files.cnblogs.com/chenli0513/MediaPlayer.7z

   public SoundPlayer sp = new SoundPlayer();
        private void Form1_Load(object sender, EventArgs e)
        {



            string path = ConfigurationManager.AppSettings["dir"].ToString();
            //string path=@"C:Documents and SettingsAdministratorMy DocumentsMy Music";

            DirectoryInfo d = new DirectoryInfo(@"C:Documents and SettingsAdministratorMy DocumentsMy Music");
            ArrayList Flst = GetAll(d,path);
            foreach (var item in Flst)
            {
                this.axWindowsMediaPlayer1.currentPlaylist.appendItem(this.axWindowsMediaPlayer1.newMedia(item.ToString()));
                //sp.SoundLocation = item.ToString();
                //sp.Load();
                //sp.Play();
            }
           
            //            for(循环你的listBox中的 列表)
            //{
            // WMPLib.IWMPMedia middleMedia = (WMPLib.IWMPMedia)MediaPlayer.newMedia(你的全路径文件名);
            // soundPlayer.currentPlaylist.appendItem(middleMedia);
            //}
            //soundPlayer.Ctlcontrols.play



        }

        private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
        {
            if ((WMPLib.WMPPlayState)e.newState == WMPLib.WMPPlayState.wmppsReady)
            {
                this.axWindowsMediaPlayer1.Ctlcontrols.play();
            }
            if (this.axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
            {
                //WMPLib.IWMPMedia oMedia = (WMPLib.IWMPMedia)MediaPlayer.("");
               // this.axWindowsMediaPlayer1.currentMedia =  (WMPLib.IWMPMedia)MediaPlayer.newMedia("fadsf");;//设定当前播放的媒体 
            }
        }

        public ArrayList GetAll(DirectoryInfo dir,string path)//搜索文件夹中的文件
        {
            ArrayList FileList = new ArrayList();

            FileInfo[] allFile = dir.GetFiles();
            foreach (FileInfo fi in allFile)
            {
                string str = string.Format("{0}/{1}", path, fi.Name);
                FileList.Add(str);
            }

            //DirectoryInfo[] allDir = dir.GetDirectories();
            //foreach (DirectoryInfo d in allDir)
            //{
            //    GetAll(d);
            //}
            return FileList;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;

            if (dt.Hour == 15 & dt.Minute == 45)
            {
                Application.Exit();
            }
        }
原文地址:https://www.cnblogs.com/chenli0513/p/3200351.html