Avatar of G Scott
G Scott
Flag for United States of America asked on

Windows Mobile 6.1 Play Sound

Howdy. I have seen a few solutions for playing a sound file on a mobile device that is running WM6+.  One of the common denominators is this line:

Import System.Media

What do I have to do to get that option? I type that and it doesn't allow me to do that. I am very green in .NET (well versed in VBA).

I am using an Intermec CK3, if that matters. I just want to play a sound so that the user knows everything is ok or not ok. (ding/buzz, respectively)

Can someone help me out with this?  I only know/use VB..C Sharp/++ scares me.

Thanks for any help you can give me.
Microsoft Development.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon

The .NET Compact Framework version 3.5 supports the SoundPlayer class, which provides an intuitive API for playing sounds in applications such as casual games. To enable casual game development, the .NET Compact Framework pushes each SoundPlayer object through WaveOut, which is the audio rendering filter in Windows Embedded CE and Windows Mobile powered devices. This filter enables the device to mix sounds.

The .NET Compact Framework 3.5 supports the following types:




For a code example that demonstrates how to use this feature, see SoundPlayer.

The differences between the .NET Compact Framework implementation and the desktop implementation of SoundPlayer include the following:

The .NET Compact Framework supports only PCM-encoded files (uncompressed sound).

On a device, more than one sound can play at the same time. On the desktop, only the last sound plays.

On a device, the application will not terminate until playback is completed. If a sound is playing in the application loop, the application will never exit. To avoid this situation, you can explicitly terminate playback by calling the Stop or Dispose method on the SoundPlayer object.

Reference From:

An alternative way to play Beeps is to use the "coredll.dll" and a file you place at your device.

Dim ExePath As String

Private Declare Function PlaySound Lib "coredll.dll" Alias "PlaySound" _
(ByVal lpszName As String, _
ByVal hMod As IntPtr, _
ByVal hwFlags As Integer) As Integer
Private Sub Beep_Test()
PlaySound(ExePath + "test.wav", IntPtr.Zero, &H1 Or &H20000)
End Sub

btw, the system.media interface is not presented in the .Net Compact Framework
Nasir Razzaq

>What do I have to do to get that option? I type that and it doesn't allow me to do that.

Have you added a reference to system.media?

Are you negating your first comment? SoundPlayer, SystemSound, and SystemSounds classes are within System.Media namespace.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

no i mean .Net Compact Framework 2.0
If you are using .Net CF 3.5 then you have no problem.
What visual studio are you using?
G Scott

I am using VS2008 with CF3.5. When I try to add a reference the .NET list is very short:

Screen of References
I don't see anything with the word Media, or similar to that at all.

asfahani - I tried your code but I am still just getting a beep instead of the wav file that I want to have played.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
G Scott

I installed a few SDKs from Intermec, but was never able to find that DLL. However, the other solution you gave worked great!! Thank you so much; I truly appreciate it.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

glad to help you, welcome anytime!