<bgsound src="你的声音文件" loop="-1">

解决方案 »

  1.   

    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 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
    }
      

  2.   

    很多人都漏掉一个参数
    SND_PURGE = 0x40这个参数就是用来中止声音的播放的,在用SND_LOOP 之后就可以用SND_PURGE 中止声音了