有关委托
private delegate void ExecuteDirective(string str, int persistence);//定义委托
private delegate void ExecuteDirective2();//定义委托
private void ReceiveMessage(string x)
{
string url = url ="D:/film/1.rmvb";//完整路径
int persistence = 20;//播放时间
switch (x)
{
case "INSERT"://插入播放
ExecuteDirective fInsert = new ExecuteDirective(mediaInsert);
this.Invoke(fInsert, new object[] { url, persistence });
//调用form中的控件方法要使用invoke来调用,否则出错
break;
case "PAUSE"://暂停
ExecuteDirective2 fPause = new ExecuteDirective2(mediaPause);
this.Invoke(fPause );
break;
case "PLAY"://从暂停处开始
ExecuteDirective2 fPlay = new ExecuteDirective2(mediaPlay);
this.Invoke(fPlay );
break;
}
}
private void mediaInsert(string url, int persistence)
{
axWindowsMediaPlayer1.URL = url;
}
private void mediaPause()//暂停
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
}
private WMPLib.WMPPlayState mediaState()//返回播放状态
{
return axWindowsMediaPlayer1.playState;
}
private void mediaStop()//停止
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
private void mediaPlay()//继续播放
{
axWindowsMediaPlayer1.Ctlcontrols.play();
}
private void Play()//继续播放
{
//播放列表
}