• 自动循环播放 播放器


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

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

    放点歌曲来听听,

    我就来写这个程序了!

    程序下载地址

    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();
                }
            }
  • 相关阅读:
    【JAVA】浅谈java枚举类
    【JAVA】浅谈java枚举类
    WinForm时间选择控件(DateTimePicker)如何选择(显示)时分秒
    WinForm时间选择控件(DateTimePicker)如何选择(显示)时分秒
    SQL Server中的between(在某个范围)
    SQL Server中的between(在某个范围)
    如何安装Microsoft网络客户端 无法访问局域网的共享文件夹
    如何安装Microsoft网络客户端 无法访问局域网的共享文件夹
    SQL Server 中WITH (NOLOCK)浅析
    SQL Server 中WITH (NOLOCK)浅析
  • 原文地址:https://www.cnblogs.com/chenli0513/p/3200351.html
Copyright © 2020-2023  润新知