public

Subversion Repositories:
[/] [BeatBox/] [BeatBox/] [PlaySoundWinCE.cs] - Rev 7

Compare with Previous - Blame


using System;

using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BeatBox
{
    class PlaySoundWinCE
    {

        [DllImport("coredll.dll")]
        public static extern bool PlaySound(string pszSound, IntPtr hMod, SoundFlags SoundFlags);



        [DllImport("coredll.dll")]
        public static extern bool PlaySound(byte[] arrBytes, IntPtr hMod, SoundFlags SoundFlags);


        /*
         *  Another API for playing sound.  SndPlayAsync allows MP3s and WMAs to be played too.
         *  There is also System.Media.SoundPlayer for .Net 3.5 and
         *  Microsoft.DirectX.AudioVideoPlayback.Audio for WinForm DirectX only
         
        [DllImport("aygshell.dll")]
        static extern uint SndOpen(string pszSoundFile, ref IntPtr phSound);

        [DllImport("aygshell.dll")]
        static extern uint SndPlayAsync(IntPtr hSound, uint dwFlags);

        [DllImport("aygshell.dll")]
        static extern uint SndClose(IntPtr hSound);

        [DllImport("aygshell.dll")]
        static extern uint SndStop(int SoundScope, IntPtr hSound);

        private const int SND_SCOPE_PROCESS = 0x1;

        IntPtr Play(string strFile)
        {
            IntPtr hSound = IntPtr.Zero;
            SndOpen(strFile, ref hSound);
            SndPlayAsync(hSound, 0);
            return hSound;
        }

        void Stop(IntPtr hSound)
        {
            SndClose(hSound);
            SndStop(SND_SCOPE_PROCESS, IntPtr.Zero);
        } 
         
        */
    }
}