- 首先需要在VS2008中加入WMP的COM控件,然后就可以将控件拖到WinForm中了,最后播放的代码是:
this.axWmp.URL = Application.StartupPath + "//bg.mp3";
this.axWmp.Ctlcontrols.play();
很简单吧,另外this.axWmp.Ctlcontrols.XXX还有很多方法控制的,可以自己参考。
当然也可以使用this.axWmp.openPlayer(Application.StartupPath + //bg.mp3);这样的代码来打开音乐播放,不过这样会弹出一个独立WMP的窗口来播放的。
C#中使用Windows Media Player播放音乐的方法
最新推荐文章于 2020-12-20 21:28:47 发布