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);
[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);
public static void Play(string fileName)
{
// filename must be absolute
// e.g. \\Program Files\\Test\\phone.mp3
SndOpen(fileName, ref hSound);
SndPlayAsync(hSound, 0);
}
public static void Stop()
{
SndClose(hSound);
SndStop(SND_SCOPE_PROCESS, IntPtr.Zero);
}
}
Tested with Windows Mobile 6.