
1:使用
控件Microsoft MutileMedia Control Version 6.0,可在Vs.net中
添加此控件. 取名为player. '
播放背景音乐 player.FileName = Application.StartupPath "\Music\GameMain.mid" player.Command = "Open" player.Command = "Play" 这种方法我测试过就可以播放wma和wmv格式的音乐文件,而且在播放wmv的时候会新建窗口 2.你可以用 directx 9 的托管DirectX.AudioVideoPlayback.DLL里面有个类命,你可以在C:的Microsoft.net的文件夹里面找到这个文件,用这个类Audio,用来播放音 乐很方便, Audio v=Audio(".mp3")v.ending +=new .....//添加事件处理函数! 在他的事件处理函数里可以写 v.open("声音文件名!") v.play()详细的可以自己处理一下就行了! 3.可以使用SoundPlayer.PlaySync 方法 来异步加载文件并播放. -------------------------------------------------------------------------------- 如何在Winform环境下,给窗体添加背景音乐? 比如: private SoundPlayer Player = new SoundPlayer()//首先NEW一个播放器 private void loadSoundAsync() { // Note: You may need to change the location specified based on // the location of the sound to be played. this.Player.SoundLocation = " http://www.tailspintoys.com/sounds/stop.wav"this.Player.LoadAsync()} private void Player_LoadCompleted( object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (this.Player.IsLoadCompleted) { this.Player.PlaySync()} } //比如这是在本地找的背景 this.axWindowsMediaPlayer1.URL = @"F:\MS\09 老鼠愛大米.mp3"this.axWindowsMediaPlayer1.Visible=false 本文来自CSDN博客,转载请标明出处: http://blog.csdn.net/alex_xhui/archive/2009/11/02/4757073.aspx主要有两种方法:
第一种,是最常用的,也是使Vb变得简单的一个优势,就是直接从工具箱中zhidao选择空间,添加到窗体中,还可以选中控件,设置各种专属性,设置好后,就无需再用代码进行设置。
第二种,比较复杂,就是直接用代码添加控件。需要用代码指定控件的大小属、位置等等各种属性,一般在Vb中用的较少。
评论列表(0条)