引用处于无效状态的 ActiveX 控件时引发的异常。
private AxMediaPlayer.AxMediaPlayer axWindowsMediaPlayer1;
if(openFileDialog1.ShowDialog()==DialogResult.OK)
{
axWindowsMediaPlayer1.FileName = openFileDialog1.FileName;
}
private AxMediaPlayer.AxMediaPlayer axWindowsMediaPlayer1;
if(openFileDialog1.ShowDialog()==DialogResult.OK)
{
axWindowsMediaPlayer1.FileName = openFileDialog1.FileName;
}
axWindowsMediaPlayer1.URL = path;
这一个可以行得通。下面一个自定义的却不可以。
AxWMPLib.AxWindowsMediaPlayer awm=new AxWMPLib.AxWindowsMediaPlayer ();
awm.URL = path; 1楼的所说的那个方法
我找不到AxMediaPlayer.AxMediaPlayer
也没有axWindowsMediaPlayer1.FileName 不知道是不是用的版本不同 我用的是vs2008
不过他没有理解你说的意思
哎,对windons的组件,其实我最近也用过AxWindowsMediaPlayer,我的心得是
你就用axWindowsMediaPlayer1.URL 来操作吧,好像他的URL是静态的,只能直接用类名来访问
不能用他的对象来调用!!!
this.Controls.Add(axWindowsMediaPlayer1);
string path =“E:/cccc/ccc.mp3”;
axWindowsMediaPlayer1.URL = path;
axWindowsMediaPlayer1.Ctlcontrols.play();
这样就可以了
必须有这个
AxWMPLib.AxWindowsMediaPlayer awm=new AxWMPLib.AxWindowsMediaPlayer ();
this.Controls.Add(awm); //必须先添加到窗体上
awm.URL = path;
this.axWindowsMediaPlayer1.URL = Application.StartupPath + "\\sound\\一万个理由.mp3";
在在工具箱空白处右击,选择项 , com+ 选择windowsmediaplayer 确定