C# 多媒體播放器

來源:互聯網
上載者:User

標籤:blog   ar   os   sp   for   on   檔案   div   log   

   //停止播放        public void stopFile()        {            axWindowsMediaPlayer1.Ctlcontrols.stop();        }        //暫停檔案        public void pauseFile()        {              axWindowsMediaPlayer1.Ctlcontrols.pause();        }        //播放檔案        public void starFile()        {            axWindowsMediaPlayer1.Ctlcontrols.play();        }        //列表清空        public void clearFile()        {            listBox1.Items.Clear();            axWindowsMediaPlayer1.Ctlcontrols.stop();        }        private void 全屏ToolStripMenuItem_Click(object sender, EventArgs e)        {            if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)            {                axWindowsMediaPlayer1.fullScreen = !axWindowsMediaPlayer1.fullScreen;            }        }   private String file = "";        List<string> list = new List<string>();        //刪除單個檔案        public void delFile()        {            for (int i = 0; i < listBox1.Items.Count; i++)            {                if (listBox1.SelectedItems.Contains(listBox1.Items[i]))                {                    listBox1.Items.Remove(listBox1.Items[i]);                    axWindowsMediaPlayer1.Ctlcontrols.stop();                }            }        }   private void 開啟ToolStripMenuItem_Click(object sender, EventArgs e)        {                      DialogResult dr = openFileDialog1.ShowDialog();            openFileDialog1.Multiselect = true;            switch (dr)            {                 case DialogResult.OK:                    file = openFileDialog1.FileName;                    list.Add(file);                    axWindowsMediaPlayer1.URL = openFileDialog1.FileName;                    listBox1.Items.Add( openFileDialog1.FileName.Substring(file.LastIndexOf("\\")+1));                    break;                case DialogResult.No:                    break;            }        }  private void button5_Click(object sender, EventArgs e)        {            starFile();        }        private void button6_Click(object sender, EventArgs e)        {            pauseFile();        }        private void button7_Click(object sender, EventArgs e)        {            stopFile();        }        //上一曲        private void button3_Click(object sender, EventArgs e)        {            for (int i = 0; i < listBox1.Items.Count; i++)            {                if (listBox1.SelectedItems.Contains(listBox1.Items[i]))                {                    //如果是頂部                    if (listBox1.SelectedIndex == 0)                    {                        MessageBox.Show("已經達到頂部");                      }                    //否則就上一曲                    else                    {                        listBox1.SetSelected(listBox1.SelectedIndex - 1, true);                        axWindowsMediaPlayer1.URL = list[listBox1.SelectedIndex];                        return;                    }                                    }            }        }        //下一曲        private void button4_Click(object sender, EventArgs e)        {            for (int i = 0; i < listBox1.Items.Count; i++)            {                if (listBox1.SelectedItems.Contains(listBox1.Items[i]))                {                    //如果是頂部                    if (listBox1.SelectedIndex == listBox1.Items.Count - 1)                    {                        MessageBox.Show("已經達到尾部部");                        //MessageBox.Show(listBox1.Items.Count.ToString());                    }                    //否則就下一曲                    else                    {                        listBox1.SetSelected(listBox1.SelectedIndex+1, true);                        //讓歌曲切換到下一曲                        axWindowsMediaPlayer1.URL = list[listBox1.SelectedIndex];                        return;                    }                }            }        }        private void 全選列表ToolStripMenuItem_Click(object sender, EventArgs e)        {                listBox1.MultiColumn = true;                   //listBox1.SetSelected(0, true);                //listBox1.SetSelected(1, true);                //listBox1.SetSelected(2, true);                        listBox1.Select();        }        private void 刪除ToolStripMenuItem_Click(object sender, EventArgs e)        {            delFile();        }        private void 播放ToolStripMenuItem_Click(object sender, EventArgs e)        {            starFile();        }        private void 停止ToolStripMenuItem_Click(object sender, EventArgs e)        {            stopFile();        }        private void 暫停ToolStripMenuItem_Click(object sender, EventArgs e)        {            pauseFile();        }        private void 快退ToolStripMenuItem_Click(object sender, EventArgs e)        {            axWindowsMediaPlayer1.Ctlcontrols.fastReverse();        }        private void 快進ToolStripMenuItem_Click(object sender, EventArgs e)        {            axWindowsMediaPlayer1.Ctlcontrols.fastForward();        }        private void 清空ToolStripMenuItem_Click(object sender, EventArgs e)        {            delFile();        }

 

C# 多媒體播放器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.