tags:

views:

574

answers:

2

Does anyone know of some mp3 playing code for the pocket PC.
I have 3 mp3s that I want to play when my application loads up, depending on how you log in.

I've used VS2005 C++ to code what I've got now.

I think code to play mp3 for the desk might do the job. But I might not have access to the library, that's why I've been specific.

+1  A: 

You can use DirectShow. Here is an example (it plays a video file, but exactly the same code will work for audio). Unfortunately, Windows Mobile lacks a suitable splitter to decode plain .mp3 files, but there is a workaround: you can add a RIFF header to your MP3s (producing MPEG-compressed WAV files).

atzz
+1  A: 

I know the question is in C++, but here is good point on this.. Also like you say, the code that works for your desk also can work on the Pocket PC.

So I worked Windows Mobile app don in C#, that had a reminder feature and we used the wmplib (Windows Media Player) Library to play songs (mp3 included).

First you need to add the wmp.dll to the references, found in c:\Windows\System32 (or what ever is your windows directory). Then you just need to code it like this:

private WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
// url is the path of the file
private void PlayFile(String url)
{

    player = new WMPLib.WindowsMediaPlayer();
    player.URL = url;
    player.settings.volume = 100;
    player.controls.play();
}

Here is the reference for this code

And for the C++ here you can find how to do it

Geries Handal
Thanks, this put me on the right track. Except that there is a GC issue with using the wmp.dll. There is a related SO question, but still have not found a working solution to the GC issue: http://stackoverflow.com/questions/2700219/why-is-this-simple-mobile-form-not-closed-when-using-the-player
pithyless