How to play mp3 file in my program?

  • Thread starter Thread starter Liren Zhao
  • Start date Start date
Here's how you can do it on the .NET Framework

In your project add a reference to the ActiveMovie control type
library, it's on the COM tab.

Then use the followint code, where fileName is the name and path of
your MP3 file.

*************************
string fileName = @"C:\music.mp3";
QuartzTypeLib.FilgraphManager filgraphManager = new
QuartzTypeLib.FilgraphManager();
QuartzTypeLib.IMediaControl mediaControl =
(QuartzTypeLib.IMediaControl)filgraphManager;
mediaControl.RenderFile(fileName);
mediaControl.Run();
*************************
Also, you can use mediaControl.Stop() to stop playint the MP3
 
....and what good is that on the CF 1.0 where COM Interop doesn't exist?!

Cheers
Daniel
 
Or use fmodce (www.fmod.org. Free for non-commercial use.

blurb: "FMOD supports 3d sound, midi, mods, mp3, ogg vorbis, wma, aiff,
recording, obstruction/occlusion, cd playback (analog or digital), cd
ripping, mmx, internet streaming, dsp effects, spectrum analysis, user
created samples and streams, synchronization support, ASIO, EAX 2&3,
C/C++/VB/Delphi and more."

Lane Kuo has written a very nice .NET CF wrapper in his smartphone alarm
project.
http://sourceforge.net/projects/spalarm/

The library can easily be extended to add support for the callbacks using
the standard technique of another native dll which posts messages to a
MessageWindow class in your .NET app.


fmodce is free for non commercial use and it rocks.
 
Sorry, a bit off topic. but can you expand on the "standard technique of
another native dll which posts messages to a MessageWindow class in your
..NET app"

cheers
 
Back
Top