国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C# winform循環(huán)播放多個(gè)視頻

2019-10-29 21:12:25
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了winform循環(huán)播放多個(gè)視頻的具體代碼,供大家參考,具體內(nèi)容如下

環(huán)境: vs2015 +winform

首先,vs自帶組件很方便,所以,用windowMediaplayer組件,如果做單曲循環(huán)播放的話,加個(gè)屬性:

axWindowsMediaPlayer1.settings.autoStart = true;      //設(shè)置自動(dòng)播放axWindowsMediaPlayer1.settings.setMode("loop", true);   //設(shè)置循環(huán)播放

言歸正傳:

一:拖入組件button  ,windowMediaplayer,listbox,timer

二:

 List<string> fileList = new List<string>();       private void button1_Click(object sender, EventArgs e)    {      fileList.Add(@"E://QLDownload/nba//Action2.mp4");      fileList.Add(@"E://QLDownload/nba//Action3.mp4");      fileList.Add(@"E://QLDownload/nba//Action4.mp4");      fileList.Add(@"E://QLDownload/nba//Action5.mp4");      for (int i = 0; i < fileList .Count ; i++)      {        listBox1.Items.Add(fileList [i]);      }      //默認(rèn)選擇第一項(xiàng)      this.listBox1.SelectedIndex = 0;      axWindowsMediaPlayer1 .URL = fileList [listBox1.SelectedIndex];      axWindowsMediaPlayer1 .Ctlcontrols.play();    } private void timer1_Tick(object sender, EventArgs e)    {      if (axWindowsMediaPlayer1 .playState == WMPLib.WMPPlayState.wmppsPlaying)      {        double d1 = Convert.ToDouble(axWindowsMediaPlayer1 .currentMedia.duration.ToString());        double d2 = Convert.ToDouble(axWindowsMediaPlayer1 .Ctlcontrols.currentPosition.ToString()) + 1;        if (d1 <= d2)        {          nextMusic(listBox1.SelectedIndex);        }      }     } private void Form1_Load(object sender, EventArgs e)    {      axWindowsMediaPlayer1 .settings.autoStart = false ;        }void nextMusic(int index)    {      //listBox1.SelectedIndices.Clear();      index++;      if (index == listBox1.Items.Count)      {        index = 0;      }      axWindowsMediaPlayer1 .URL = fileList [index];      listBox1.SelectedIndex = index;      axWindowsMediaPlayer1 .Ctlcontrols.play();    }

提醒: 注意各個(gè)組件的自身屬性,運(yùn)行不了,及時(shí)調(diào)屬性, .

由于需求原因,不讓選擇文件,所以在代碼里,默認(rèn)添加的, 并把listbox隱藏了.

問題: 下面就要解決路徑問題了.如果打包,必須弄成項(xiàng)目路徑或者網(wǎng)絡(luò)路徑, 視頻文件并不支持內(nèi)置資源.

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到c#教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 搜索| 商河县| 长治市| 繁昌县| 江门市| 册亨县| 邯郸县| 珲春市| 得荣县| 蓬莱市| 灵山县| 民乐县| 英吉沙县| 肇东市| 新建县| 宝山区| 治多县| 东兰县| 阳谷县| 山东| 武山县| 永福县| 泰州市| 太保市| 博爱县| 台湾省| 嵊泗县| 通江县| 通辽市| 文登市| 宜兰县| 台南县| 祁连县| 收藏| 安国市| 鹿泉市| 巫山县| 闵行区| 武冈市| 房产| 汨罗市|