C#程序自作音樂視頻播放器_第1頁
C#程序自作音樂視頻播放器_第2頁
C#程序自作音樂視頻播放器_第3頁
C#程序自作音樂視頻播放器_第4頁
C#程序自作音樂視頻播放器_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、一個簡單的音樂視頻系統(tǒng)建立一個項目:閨戶控忤五WPF控制互應(yīng)月程序WPF自走性庫譚IWPF百¥Windows.強善Windows的誄在用慢不VisualC#VisualC®帥山C#VisualC*,NETfratntwork3,S”用序防二班認他*|WindawsFcrmsApphcatiQn倒建制昭湖S一J為瞬北右理到津自最必流比副源優(yōu)君曾理IW聯(lián)嘰模板名容圖h特餐L1:婢夬75sg已空裝的出板FM咆序耍小suibIC*Window?WtbOfficeClcMidReportingSharePointSilveirlightWCFWorkflow釀R他謂三要佗項目聶出H次

2、方索名林(M):WindowsFormsApplicati&nJTJM¥3CI-mthLaIgCqr例MVm.Htirdt'igNa-k'i9ilDrB-indhnSctifcvBajW£"ChKWMXLhKkadLflHilaHCckrEN-C4»¥B«k''口mridvjDitaSDrttTrntKktiD*edflrnpykI口ry!t»!rherOo9iHrUpCrnmEiri»Pr&FidFeE>e«<ogiFi*5好ImfMiIche

3、rAwrLayculHWiaiFcHir亳rovn«*里演.FonfliaiogiGrmipKacH文1rmifldUnVisualC#WijuslC*明5uadCflVisualC*rPrtaigIftfpn*l%«em審mfcfFoe,二“;】F.1-unnljMftdlx©ndiglMEi4M4»1Sis臉中XI聲JuinSanPMi的C«rrhefnwT»gIeTcpMosIE”TE-5Btt?SaEEv¥.立“)字口回生a)3sauiMjeajUKn<x至gqmz分向刖*cm)*6e,,/>m.j-5:

4、1電二:3:3次。"匚1'I.:Jr:叱,.::.二,/8WcdcMgMBtfl*rp«4mfu»1B%4k立旃Hh訕V)r口后一生的3satWMjbaajmenmaoiw也分向刖«ctw”刈心了am助生怛受-MkrosghVfhjbIMdiCdTKflJ文忤舊MIDSffiiViCSiEI±JEi£lAElpjStJM1應(yīng)由J*U值工電荒叩黜嗯廿1陋工二理W»HI±1,。且:.:i=,+,!*公弓A二|年?當|信臺處圃81口:aiu>4ni7/山|月口圓叁|中西轉(zhuǎn)客”就告與恒向玷叫|珠!>Tm

5、yDinrlDryiwrdivr"iLtnnanUpCtmnQError1口vidvrQU國FIKmimqaftdiirGtumpotHifefrentierHSilrdli1lniaudLi>lAUikUbdgSrUvMewALiafcelMtMJfltQiftieMoMfCderdiarNodMcoAN,i妙知口0<*門FmLn|£tt|FarmLcs方需用項EHxJIa固浦iam心feWMPLifc-QSpTltniQ5時20*中Q5詞eJ曲-Q:5問Eiq*ia"Q的看iEiJO中明Q珈MEiJaurQffTtrnJhil-QtfTlmnLir

6、©WMHh"fnrrnl.ci代碼:點擊窗體進入usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;namespaceWindows音樂播放器publicpartialclassForm1:FormpublicForm1()InitializeComponent()

7、;/定義播放列表數(shù)的最大值/選中的媒體文件的索引/選中的音樂文件/控制是否循環(huán)播放stringfileList=newstring10000;intnumOfMusic;intselectOne;boolplayOne=false;publicvoidAddFile(stringpath)if(numOfMusic<10000)numOfMusic+=1;fileListnumOfMusic=path;)else(MessageBox.Show("不能添力口文件!","播放列表已滿");)publicvoidAddFiles(stringpath,

8、ListBoxlstFiles)(DirectoryInfodir=newDirectoryInfo(path);foreach(FileInfofindir.GetFiles("*.mp3")(AddFile(f.FullName);inti;stringstrFile=Convert.ToString(numOfMusic);for(i=1;i<=5-strFile.Length;i+)(strFile+="")strFile=f.Name;lstFileList.Items.Add(strFile);)foreach(DirectoryInf

9、odindir.GetDirectories()(AddFiles(d.FullName,lstFileList);)publicvoidDelFile(intselectNum)(inti;for(i=selectNum;i<=numOfMusic-1;i+)(fileListi=fileListi+1;)numOfMusic-=1;)publicvoidCloseBtn()(btnPlay.Enabled=false;btnBack.Enabled=false;btnForward.Enabled=false;btnStop.Enabled=false;btnReplay.Enabl

10、ed=false;btnDelete.Enabled=false;privatevoidForm1_Load(objectsender,EventArgse)lstFileList.Items.CopyTo(fileList,0);/將列表框(lstFileList)中的列表項全部復制到數(shù)組(fileList)中/選中第一個媒體文件numOfMusic=0;CloseBtn();/播放選中的媒體文件publicvoidPlay(intselectNum)mediaPlayer.URL=fileListselectNum;this.Text="正在播放-"+lstFileLi

11、st.SelectedItem.ToString();publicvoidOpenBtn()btnPlay.Enabled=true;btnBack.Enabled=true;btnForward.Enabled=true;privatevoidaxWindowsMediaPlayer1_Enter(objectsender,EventArgse)privatevoidbutAddFile_Click(objectsender,EventArgse)文件名/設(shè)置默認inti;odlgMedia.FileName=""/設(shè)置默認路徑/設(shè)置文件類型odlgMedia.Initi

12、alDirectory="C:"odlgMedia.Filter="mp3文件|*.mp3|所有文件|*.*"if(odlgMedia.ShowDialog()=DialogResult.OK)(stringpath=odlgMedia.FileName;FileInfof=newFileInfo(path);AddFile(f.FullName);stringstrFile=Convert.ToString(numOfMusic);for(i=1;i<=5-strFile.Length;i+)(strFile+="")strF

13、ile=f.Name;lstFileList.Items.Add(strFile);if(lstFileList.Items.Count>0)(OpenBtn();)privatevoidbtnAddFiles_Click(objectsender,EventArgse)(fbdlaMedia.SelectedPath="c:"fbdlaMedia.ShowNewFolderButton=true;fbdlaMedia.Description="請選擇媒體文件目錄:"fbdlaMedia.ShowNewFolderButton=false;if(f

14、bdlaMedia.ShowDialog()=DialogResult.OK)(AddFiles(fbdlaMedia.SelectedPath,lstFileList);if(lstFileList.Items.Count>0)(OpenBtn();)privatevoidbtnDelete_Click(objectsender,EventArgse)(inti=lstFileList.SelectedIndex;if(lstFileList.SelectedIndex>=0)(if(selectOne=lstFileList.SelectedIndex+1)&&

15、(mediaPlayer.URL!="")(MessageBox.Show("不能刪除正在播放的文件","錯誤");else(DelFile(i+1);lstFileList.Items.RemoveAt(i);if(i<lstFileList.Items.Count)(lstFileList.SelectedIndex=i;elseif(lstFileList.Items.Count=0)(CloseBtn();else(lstFileList.SelectedIndex=0;privatevoidbtnPlay_Click(

16、objectsender,EventArgse)(if(lstFileList.SelectedIndex<0)(selectOne=1;lstFileList.SelectedIndex=0;else(selectOne=lstFileList.SelectedIndex+1;Play(selectOne);tmrMedia.Enabled=true;btnStop.Enabled=true;btnReplay.Enabled=true;)privatevoidlstFileList_SelectedIndexChanged(objectsender,EventArgse)(btnDe

17、lete.Enabled=true;)privatevoidbtnBack_Click(objectsender,EventArgse)(if(lstFileList.SelectedIndex>0)(lstFileList.SelectedIndex-=1;)elseif(lstFileList.SelectedIndex=0)(lstFileList.SelectedIndex=lstFileList.Items.Count-1;)else(lstFileList.SelectedIndex=numOfMusic-1;)selectOne=lstFileList.SelectedIn

18、dex+1;Play(selectOne);btnStop.Enabled=true;btnReplay.Enabled=true;)privatevoidbtnForward_Click(objectsender,EventArgse)(if(lstFileList.SelectedIndex<lstFileList.Items.Count-1)(lstFileList.SelectedIndex=lstFileList.SelectedIndex+1;)else(if(lstFileList.SelectedIndex>0)(lstFileList.SelectedIndex=

19、0;selectOne=IstFileList.SelectedIndex+1;Play(selectOne);btnStop.Enabled=true;btnReplay.Enabled=true;privatevoidbtnStop_Click(objectsender,EventArgse)mediaPlayer.URL=""this.Text="媒體播放器"tmrMedia.Enabled=false;btnReplay.Enabled=false;lstFileList.SelectedIndex=selectOne-1;privatevoidbtnReplay_Click(objectsender,EventArgse)if(playOne=true)playOne=false;btnReplay.FlatStyle=FlatStyle.Standard;/設(shè)置按鈕外觀為三維btnReplay.Text=,單曲循環(huán)";elseplayOne=true;btnReplay.FlatStyle=FlatStyle.Popup;/設(shè)置按鈕外觀為平面顯btnReplay.Text=,取消循環(huán)";lstFileList.SelectedIndex=selectOne-1;pr

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論