怎样循环播放声音 <bgsound src="你的声音文件" loop="-1"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 call win32 api playsound////////////////////////////////////try the following code in the correct places:[DllImport("user32.dll", EntryPoint="MessageBeep")]private static extern bool Win32_MessageBeep(uint uType);[DllImport("winmm.dll", EntryPoint="PlaySound")]private static extern bool Win32_PlaySound(string pszSound, IntPtr hmod,uint fdwSound);/// <summary>/// Plays a standard Windows sound./// </summary>/// <param name="beepStyle">The type of beep to play.</param>public static void Beep(BeepStyle beepStyle){ Win32_MessageBeep((uint) beepStyle);}/// <summary>/// Plays a wave audio file./// </summary>/// <param name="path">The wave audio file to play.</param>/// <param name="asynchronous">Determines if the file is playedasynchronously from execution of this thread.</param>/// <param name="loop">Determines if playback loops.</param>/// <param name="doNotStopPlay">Determines if previously played wave audiois stopped before playing a new file.</param>public static void PlaySound(string path, bool asynchronous, bool loop, booldoNotStopPlay){ Win32_PlaySound(path, IntPtr.Zero, (uint) ((asynchronous ?PlaySoundMessage.SND_ASYNC : PlaySoundMessage.SND_SYNC) | (loop ?PlaySoundMessage.SND_LOOP : 0) | (doNotStopPlay ?PlaySoundMessage.SND_NOSTOP : 0) | PlaySoundMessage.SND_FILENAME));}/// <summary>/// Stops all wave audio played with the PlaySound method./// </summary>public static void StopSound(){ Win32_PlaySound(null, IntPtr.Zero, 0);}/// <summary>/// Represents different beep styles./// </summary>public enum BeepStyle{ PCSpeaker = -1, Default = 0x0, Error = 0x10, Question = 0x20, Warning = 0x30, Information = 0x40}[Flags()]internal enum PlaySoundMessage{ SND_SYNC = 0x0000, SND_ASYNC = 0x0001, SND_LOOP = 0x0008, SND_NOSTOP = 0x0010, SND_FILENAME = 0x00020000} 很多人都漏掉一个参数SND_PURGE = 0x40这个参数就是用来中止声音的播放的,在用SND_LOOP 之后就可以用SND_PURGE 中止声音了 类 实例相等的问题,== .Equal() 关于图片加载,怎么样做程序加载一次,而在程序里多次用.并且不用全局变量. 为什么在线程中无法获取复制板上的数据 RDLC报表高手请进,急啊!!!! 怎么编辑ascx文件?? 怎样把webBorower的url指向一个web地址 线程中如何抛出错误让主线程捕获,在界面显示出来,还有线程的多写一读,如何实现。 有人知道OPX协议是怎么一回事吗? ZedGraph控件问题? 连接数据库 C#如何播放VCD(VCD和rm文件)和音乐(mp3等) 怎么进行面向对象的分析和设计啊
////////////////////////////////////
try the following code in the correct places:[DllImport("user32.dll", EntryPoint="MessageBeep")]
private static extern bool Win32_MessageBeep(uint uType);
[DllImport("winmm.dll", EntryPoint="PlaySound")]
private static extern bool Win32_PlaySound(string pszSound, IntPtr hmod,
uint fdwSound);/// <summary>
/// Plays a standard Windows sound.
/// </summary>
/// <param name="beepStyle">The type of beep to play.</param>
public static void Beep(BeepStyle beepStyle)
{
Win32_MessageBeep((uint) beepStyle);
}/// <summary>
/// Plays a wave audio file.
/// </summary>
/// <param name="path">The wave audio file to play.</param>
/// <param name="asynchronous">Determines if the file is played
asynchronously from execution of this thread.</param>
/// <param name="loop">Determines if playback loops.</param>
/// <param name="doNotStopPlay">Determines if previously played wave audio
is stopped before playing a new file.</param>
public static void PlaySound(string path, bool asynchronous, bool loop, bool
doNotStopPlay)
{
Win32_PlaySound(path, IntPtr.Zero, (uint) ((asynchronous ?
PlaySoundMessage.SND_ASYNC : PlaySoundMessage.SND_SYNC) | (loop ?
PlaySoundMessage.SND_LOOP : 0) | (doNotStopPlay ?
PlaySoundMessage.SND_NOSTOP : 0) | PlaySoundMessage.SND_FILENAME));
}/// <summary>
/// Stops all wave audio played with the PlaySound method.
/// </summary>
public static void StopSound()
{
Win32_PlaySound(null, IntPtr.Zero, 0);
}/// <summary>
/// Represents different beep styles.
/// </summary>
public enum BeepStyle
{
PCSpeaker = -1,
Default = 0x0,
Error = 0x10,
Question = 0x20,
Warning = 0x30,
Information = 0x40
}[Flags()]
internal enum PlaySoundMessage
{
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_FILENAME = 0x00020000
}
SND_PURGE = 0x40这个参数就是用来中止声音的播放的,在用SND_LOOP 之后就可以用SND_PURGE 中止声音了