OpenFileDialog opfPlayer = new OpenFileDialog();
DialogResult result = opfPlayer.ShowDialog();
if (result == DialogResult.OK)
{
string file = opfPlayer.FileName;
//被播放文件地址
axWindowsMediaPlayer1.URL = file;
}
DialogResult result = opfPlayer.ShowDialog();
if (result == DialogResult.OK)
{
string file = opfPlayer.FileName;
//被播放文件地址
axWindowsMediaPlayer1.URL = file;
}
改为 if (opfPlayer.ShowDialog() == DialogResult.OK)//这个又打开一次
{
string file = opfPlayer.FileName;
//被播放文件地址
axWindowsMediaPlayer1.URL = file;
}
OpenFileDialog opfPlayer = new OpenFileDialog();
//DialogResult result = opfPlayer.ShowDialog();
if (opfPlayer.ShowDialog() == DialogResult.OK)
{
string file = opfPlayer.FileName;
//被播放文件地址
axWindowsMediaPlayer1.URL = file;
//把文件名称添加到播放列表中
listForm.addFile(file);
}
改为它之后还是不行,依旧打开两次
//DialogResult result = opfPlayer.ShowDialog();
if (opfPlayer.ShowDialog() == DialogResult.OK)
{
string file = opfPlayer.FileName;
//被播放文件地址
//axWindowsMediaPlayer1.URL = file;
//把文件名称添加到播放列表中
//listForm.addFile(file);
}
用上面的代码测试,只是打开一次的亚
{
MainForm mainForm = this;
listForm = new ListForm(ref mainForm);
InitializeComponent();
//选择文件事件
//buttonOpenFile.Click += new EventHandler(buttonOpenFile_Click);
}
我把那句注释掉就好了,谢谢大家哈