原文链接:https://blog.csdn.net/softimite_zifeng/article/details/53184147
使用axWindowsMediaPlayer的COM组件播放.mp3或.avi音乐文件
1) 加载COM组件:ToolBox->Choose Items->COM Components->Window Media Player。
2) 把Windows Media Player控件拖到窗体中,把axWindowsMediaPlay1的URL属性设置为.mp3或.avi音乐文件的路径,运行程序即可。
3) 使用Windows Media Player循环播放音乐文件:
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
{
Thread thread = new Thread(new ThreadStart(PlayThread));
thread.Start();
}
}
private void PlayThread()
{
axWindowsMediaPlayer1.URL = @"D:\TestMusic.avi"; //音乐文件
axWindowsMediaPlayer1.Ctlcontrols.play();
}