Playing MP3 with windows mobile

It took me quite a time finding useful hints on how to play MP3 with Windows Mobile. So here is what was found:

public class Sound
static IntPtr hSound = IntPtr.Zero;
const int SND_SCOPE_PROCESS = 0x1;[DllImport("aygshell.dll")]
static extern uint SndOpen(string pszSoundFile, ref IntPtr phSound);

static extern uint SndPlayAsync(IntPtr hSound, uint dwFlags);

static extern uint SndClose(IntPtr hSound);

static extern uint SndStop(int SoundScope, IntPtr hSound);

public static void Play(string fileName)
// filename must be absolute
// e.g. <a href="/////Program">\\Program</a> Files\\Test\\phone.mp3
SndOpen(fileName, ref hSound);
SndPlayAsync(hSound, 0);

public static void Stop()
SndStop(SND_SCOPE_PROCESS, IntPtr.Zero);

Tested with Windows Mobile 6.

Playing MP3 with windows mobile

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s