C#制作简易播放器

.net framework里有了许多COM组件,我们可以根据应用程序的需要来使用这些组件,不用自己再去 “造轮子”了。<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

第一个示例是来制作一个VCD播放器.这里我使用了Windows自带的Media Play来播放多媒体文件。

06121401.JPG

选择工具箱’—‘组件,右击,选择添加/移除项’—‘COM组件(如果你是第一次使用Windows Media Play控件,在列表中是没有这个控件的,可以在系统文件夹下找到,一般是在C:\Windows/System32/msdxm.ocx,把这个控件加入到控件列表中,就可以使用了。

代码如下:

None.gif using  System;
None.gif
using  System.Drawing;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Windows.Forms;
None.gif
using  System.Data;
None.gif
None.gif
namespace  MPlayDemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public class Form1 : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private AxMediaPlayer.AxMediaPlayer axMediaPlayer1;
InBlock.gif    
InBlock.gif    
InBlock.gif        
public Form1()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            InitializeComponent();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif            
dot.gif#region 
InBlock.gif        
private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.axMediaPlayer1 = new AxMediaPlayer.AxMediaPlayer();
InBlock.gif            
// 
InBlock.gif            
// axMediaPlayer1
InBlock.gif            
// 
InBlock.gif
            this.axMediaPlayer1.Dock = System.Windows.Forms.DockStyle.Top;
InBlock.gif            
this.axMediaPlayer1.Location = new System.Drawing.Point(00);
InBlock.gif            
this.axMediaPlayer1.Name = "axMediaPlayer1";
InBlock.gif            
this.axMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMediaPlayer1.OcxState")));
InBlock.gif            
this.axMediaPlayer1.Size = new System.Drawing.Size(488376);
InBlock.gif            
this.axMediaPlayer1.TabIndex = 0;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif        
private void btnPlay_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.axMediaPlayer1.FileName.Trim()=="")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this," 请选择要播放的文件!!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
this.axMediaPlayer1.Play();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnPause_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.axMediaPlayer1.FileName.Trim()=="")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this," 请选择要播放的文件!!!"," 信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
this.axMediaPlayer1.Pause();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnStop_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.axMediaPlayer1.FileName.Trim()=="")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择要播放的文件","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif                
return;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
this.axMediaPlayer1.Stop();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
InBlock.gif        
private void menuItem3_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Application.Exit();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void menuItem2_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.openFileDialog1.ShowDialog();
InBlock.gif            
string strFileName = this.openFileDialog1.FileName;
InBlock.gif            
if(strFileName.Trim()=="")
InBlock.gif                
return;
InBlock.gif            
this.axMediaPlayer1.FileName = strFileName;
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void menuItem4_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif                    
this.axMediaPlayer1.AboutBox();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void menuItem5_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.axMediaPlayer1.FastForward();
InBlock.gif    
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

InBlock.gif

第二个示例是制作一个DVD播放器:

06121402.JPG

选择工具箱’—‘组件,右击,选择添加/移除项’—‘COM组件“MSWebDVD
这个控件加入到控件列表中,就可以使用了。

代码如下:

None.gif using  System;
None.gif
using  System.Drawing;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Windows.Forms;
None.gif
using  System.Data;
None.gif
None.gif
namespace  DVDPlayDemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public class Form1 : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private AxMSWEBDVDLib.AxMSWebDVD axMSWebDVD1;
InBlock.gif    
InBlock.gif
InBlock.gif        
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
Windows#region Windows                
InBlock.gif        
private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif                
this.axMSWebDVD1 = new AxMSWEBDVDLib.AxMSWebDVD();
InBlock.gif        
InBlock.gif            
// 
InBlock.gif            
// axMSWebDVD1
InBlock.gif            
// 
InBlock.gif
            this.axMSWebDVD1.Dock = System.Windows.Forms.DockStyle.Top;
InBlock.gif            
this.axMSWebDVD1.Enabled = true;
InBlock.gif            
this.axMSWebDVD1.Location = new System.Drawing.Point(00);
InBlock.gif            
this.axMSWebDVD1.Name = "axMSWebDVD1";
InBlock.gif            
this.axMSWebDVD1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMSWebDVD1.OcxState")));
InBlock.gif            
this.axMSWebDVD1.Size = new System.Drawing.Size(504320);
InBlock.gif            
this.axMSWebDVD1.TabIndex = 0;
InBlock.gif
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif    
InBlock.gif
InBlock.gif        
private void btnPlay_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axMSWebDVD1.Play();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(System.Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(ex.Message.ToString());
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnPause_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axMSWebDVD1.Pause();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(System.Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(ex.Message.ToString());
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnStop_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axMSWebDVD1.Stop();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(System.Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(ex.Message.ToString());
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnOut_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axMSWebDVD1.Eject();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(System.Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(ex.Message.ToString());
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

第三个示例是制作一个Flash播放器。选择工具箱’—‘组件,右击,选择添加/移除项’—‘COM组件“Shockwave Flash Object”这个控件加入到控件列表中,就可以使用了。

06121403.JPG

None.gif using  System;
None.gif
using  System.Drawing;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Windows.Forms;
None.gif
using  System.Data;
None.gif
None.gif
namespace  FlashPlayDemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public class Form1 : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif    
InBlock.gif        
private AxShockwaveFlashObjects.AxShockwaveFlash axShockwaveFlash1;
InBlock.gif    
InBlock.gif    
InBlock.gif
InBlock.gif    
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
dot.gif#region 
InBlock.gif        
private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif        
InBlock.gif            
this.axShockwaveFlash1 = new AxShockwaveFlashObjects.AxShockwaveFlash();
InBlock.gif        
InBlock.gif            
// 
InBlock.gif            
// axShockwaveFlash1
InBlock.gif            
// 
InBlock.gif
            this.axShockwaveFlash1.Dock = System.Windows.Forms.DockStyle.Top;
InBlock.gif            
this.axShockwaveFlash1.Enabled = true;
InBlock.gif            
this.axShockwaveFlash1.Location = new System.Drawing.Point(00);
InBlock.gif            
this.axShockwaveFlash1.Name = "axShockwaveFlash1";
InBlock.gif            
this.axShockwaveFlash1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axShockwaveFlash1.OcxState")));
InBlock.gif            
this.axShockwaveFlash1.Size = new System.Drawing.Size(680312);
InBlock.gif            
this.axShockwaveFlash1.TabIndex = 0;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif        
private void menuItem2_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axShockwaveFlash1.Movie = this.openFileDialog1.FileName;
InBlock.gif                
this.Text = "播放的是-"+this.openFileDialog1.FileName;
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnPlay_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axShockwaveFlash1.Play();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择文件!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnStop_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axShockwaveFlash1.Stop();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择文件!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnFisrt_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axShockwaveFlash1.Rewind();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择文件!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnLast_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axShockwaveFlash1.Back();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择文件!!!","信息提示“,MessageBoxButtons.OK,MessageBoxIcon.Information);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnNext_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axShockwaveFlash1.Forward();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择文件!!!","信息提示”,MessageBoxButtons.OK,MessageBoxIcon.Information);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

第四个示例是制作一个RealPlay播放器。选择工具箱’—‘组件,右击,选择添加/移除项’—‘COM组件‘,“RealPlayer G2 Control”这个控件加入到控件列表中,就可以使用了。

06121404.JPG

为了简单起见,就直接使用它的控制面板了,代码如下:

None.gif using  System;
None.gif
using  System.Drawing;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Windows.Forms;
None.gif
using  System.Data;
None.gif
None.gif
namespace  RealPlayDemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public class Form1 : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private AxRealAudioObjects.AxRealAudio axRealAudio1;
ContractedSubBlock.gifExpandedSubBlockStart.gif            
dot.gif#region 
InBlock.gif        
private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif        
InBlock.gif            
this.axRealAudio1 = new AxRealAudioObjects.AxRealAudio();
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif        
private void menuItem2_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axRealAudio1.Source = this.openFileDialog1.FileName;
InBlock.gif                
this.axRealAudio1.DoPlay();
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void menuItem3_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Application.Exit();
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

最后一个示例是对第一个Windows Media Play播放器的扩展,用它来制作一个Mp3播放器。选择工具箱’—‘组件,右击,选择添加/移除项’—‘COM组件‘,“Windows Media Play”这个控件加入到控件列表中,就可以使用了。

06121405.JPG

代码如下:

None.gif using  System;
None.gif
using  System.Drawing;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Windows.Forms;
None.gif
using  System.Data;
None.gif
using  System.IO;
None.gif
None.gif
namespace  MP3PlayerDemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
InBlock.gif    
public class Form1 : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private AxMediaPlayer.AxMediaPlayer axMediaPlayer1;
InBlock.gif    
ContractedSubBlock.gifExpandedSubBlockStart.gif        
dot.gif#region
InBlock.gif        
private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.axMediaPlayer1 = new AxMediaPlayer.AxMediaPlayer();
InBlock.gif            
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif        
private void menuItem3_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Application.Exit();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void menuItem2_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.listView1.Items.Clear();
InBlock.gif                
string[] FileNames = this.openFileDialog1.FileNames;
InBlock.gif                
foreach(string fName in FileNames)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    System.IO.FileInfo fInfo 
= new FileInfo(fName);
InBlock.gif                    
float fSize = (float)fInfo.Length/(1024*1024);
InBlock.gif                    
this.axMediaPlayer1.FileName = fName;
InBlock.gif                    
this.axMediaPlayer1.Stop();
InBlock.gif                    
string author = this.axMediaPlayer1.GetMediaInfoString(MediaPlayer.MPMediaInfoType.mpClipAuthor);
InBlock.gif                    
string shortFileName = fName.Substring(fName.LastIndexOf("\\")+1);
InBlock.gif                    shortFileName 
= shortFileName.Substring(0,shortFileName.Length-4);
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
string[] subItem = dot.gif{shortFileName,author,fSize.ToString().Substring(0,4)+"M",fName};
InBlock.gif                    ListViewItem item 
= new ListViewItem(subItem);
InBlock.gif                    
this.listView1.Items.Add(item);
InBlock.gif                    
this.listView1.Items[0].Selected = true;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnPlay_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.listView1.Items.Count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(this.listView1.SelectedItems.Count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
int pos = this.listView1.SelectedItems[0].Index;
InBlock.gif                    
string fName = this.listView1.Items[pos].SubItems[3].Text;
InBlock.gif                    
this.axMediaPlayer1.FileName = fName;
InBlock.gif                    
this.axMediaPlayer1.Play();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    MessageBox.Show(
this,"ÇëÑ¡ÔñÒª²¥•ÅµÄ¸èÇú!!!","ÐÅÏ¢Ìáʾ",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnPause_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.axMediaPlayer1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axMediaPlayer1.Pause();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this,"请选择要播放的歌曲!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnStop_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.axMediaPlayer1.FileName.Length>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.axMediaPlayer1.Stop();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
this," 请选择要播放的歌曲!!!"," 信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnLast_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.listView1.Items.Count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(this.listView1.SelectedItems.Count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
int pos = this.listView1.SelectedItems[0].Index;
InBlock.gif                    
if(pos>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
this.listView1.Items[pos-1].Selected = true;
InBlock.gif                        
string fName = this.listView1.Items[pos-1].SubItems[3].Text;
InBlock.gif                        
this.axMediaPlayer1.FileName = fName;
InBlock.gif                        
this.axMediaPlayer1.Play();
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        MessageBox.Show(
this,"已经是第一首歌曲了!!!"," 信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    MessageBox.Show(
this," 请选择要播放的歌曲!!!"," 信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void btnNext_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.listView1.Items.Count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(this.listView1.SelectedItems.Count>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
int pos = this.listView1.SelectedItems[0].Index;
InBlock.gif                    
if(pos<this.listView1.Items.Count-1)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
this.listView1.Items[pos+1].Selected = true;
InBlock.gif                        
string fName = this.listView1.Items[pos+1].SubItems[3].Text;
InBlock.gif                        
this.axMediaPlayer1.FileName = fName;
InBlock.gif                        
this.axMediaPlayer1.Play();
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        MessageBox.Show(
this,"已经是最后一首歌曲了!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    MessageBox.Show(
this," 请选择要播放的歌曲!!!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
None.gif
None.gif
None.gif
None.gif
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值