Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PlaySound on windows mobile device

Status
Not open for further replies.

ralphtrent

Programmer
Jun 2, 2003
958
US
Hello
I am trying to play a sound on my windows mobile device. here is my code.

I have found the following pInvoke code to call to the CoreDll.dll file which I am able to put into my code and build successfully
Code:
private enum SND
        {
            SYNC = 0x0000,
            ASYNC = 0x0001,
            NODEFAULT = 0x0002,
            MEMORY = 0x0004,
            LOOP = 0x0008,
            NOSTOP = 0x0010,
            NOWAIT = 0x00002000,
            ALIAS = 0x00010000,
            ALIAS_ID = 0x00110000,
            FILENAME = 0x00020000,
            RESOURCE = 0x00040004
        }

        [DllImport("CoreDll.dll", EntryPoint = "PlaySound", SetLastError = true)]
        private extern static int PlaySound(string szSound, IntPtr hMod, int flags);
        public static void PlaySound(string fileName)
        {
            try
            {
                PlaySound(fileName, IntPtr.Zero, (int)(SND.SYNC | SND.FILENAME));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }

I call this by calling
Code:
PlaySound(lstrWavePath);

The sound is never heard. I Have verified the file (lstrWavePath) is legit and when I debug line by line, i never fail. Any idea's?

Thanks,
RalphTrent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top