如下的内容是关于C#播放背景音乐的几种方法的内容,希望能对大伙有所帮助。
System.Media.SystemSounds.Asterisk.Play();
System.Media.SystemSounds.Beep.Play();
System.Media.SystemSounds.Exclamation.Play();
System.Media.SystemSounds.Hand.Play();
System.Media.SystemSounds.Question.Play();
2.使用System.Media.SoundPlayer播放wav,mp3 System.Media.SoundPlayersp=newSoundPlayer(); sp.SoundLocation=@"恋爱ing.wav"; sp.PlayLooping();注:使用这种方法,总是提示出该文件不是波形文件,很郁闷,还是没有找出原因!!使用VS2008的话,直接添加System.Media命名空间即可!很简单!3.使用MCICommandString多媒体设备程序接口播放mp3,avi等
using System.Runtime.InteropServices;
public static uint SND_ASYNC = 0x0001;
public static uint SND_FILENAME = 0x00020000;
[DllImport("winmm.dll")]