C# winform循環(huán) 多個(gè)視頻
本文實(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隱藏了.
問(wèn)題: 下面就要解決路徑問(wèn)題了.如果打包,必須弄成項(xiàng)目路徑或者網(wǎng)絡(luò)路徑, 視頻文件并不支持內(nèi)置資源.
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
上一篇:silverlight實(shí)現(xiàn)圖片局部放大效果的方法
欄 目:C#教程
下一篇:C#中static void Main(string[] args) 參數(shù)示例詳解
本文標(biāo)題:C# winform循環(huán) 多個(gè)視頻
本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/5833.html
您可能感興趣的文章
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10WinForm實(shí)現(xiàn)仿視頻 器左下角滾動(dòng)新聞效果的方法
- 01-10C#實(shí)現(xiàn)Winform中打開(kāi)網(wǎng)頁(yè)頁(yè)面的方法
- 01-10winform實(shí)現(xiàn)創(chuàng)建最前端窗體的方法
- 01-10WinForm實(shí)現(xiàn)自定義右下角提示效果的方法
- 01-10.net2.0+ Winform項(xiàng)目實(shí)現(xiàn)彈出容器層
- 01-10winform 實(shí)現(xiàn)控制輸入法
- 01-10WinForm實(shí)現(xiàn)程序一段時(shí)間不運(yùn)行自動(dòng)關(guān)閉的方法
- 01-10Winform消除button按下出現(xiàn)的虛線簡(jiǎn)單實(shí)現(xiàn)方法


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10C#通過(guò)反射獲取當(dāng)前工程中所有窗體并
- 01-10關(guān)于ASP網(wǎng)頁(yè)無(wú)法打開(kāi)的解決方案
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10C#實(shí)現(xiàn)txt定位指定行完整實(shí)例
- 01-10WinForm實(shí)現(xiàn)仿視頻 器左下角滾動(dòng)新
- 01-10C#停止線程的方法
- 01-10C#實(shí)現(xiàn)清空回收站的方法
- 01-10C#通過(guò)重寫(xiě)Panel改變邊框顏色與寬度的
- 01-10C#實(shí)現(xiàn)讀取注冊(cè)表監(jiān)控當(dāng)前操作系統(tǒng)已
隨機(jī)閱讀
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 04-02jquery與jsp,用jquery
- 01-10C#中split用法實(shí)例總結(jié)
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 01-11Mac OSX 打開(kāi)原生自帶讀寫(xiě)NTFS功能(圖文
- 01-10delphi制作wav文件的方法