how do play mp3 with c# ???

  • Thread starter Thread starter Du Dang
  • Start date Start date
D

Du Dang

i'm making an alarm clock
and i wanna allow the user to choose their own wake up tune

which method is the best way to go ???

thanks
 
If you can make your sound file a wav file:

using System.Runtime.InteropServices;

///in a class WaveSound, have:

public static void PlaySound()

{

String fileName = @"C:/Windows/Media/tada.wav";

PlaySound(fileName,0,1);

}

[DllImport("winmm.dll")]

private static extern bool PlaySound(string lpszName, int hModule, int
dwFlags);



and then when you want to play the sound

WaveSound.PlaySound();
 
thanks Fred !!!

i guess i have to make due with wav format

thanks again for helping out,

Du

Fred Mellender said:
If you can make your sound file a wav file:

using System.Runtime.InteropServices;

///in a class WaveSound, have:

public static void PlaySound()

{

String fileName = @"C:/Windows/Media/tada.wav";

PlaySound(fileName,0,1);

}

[DllImport("winmm.dll")]

private static extern bool PlaySound(string lpszName, int hModule, int
dwFlags);



and then when you want to play the sound

WaveSound.PlaySound();

Du Dang said:
i'm making an alarm clock
and i wanna allow the user to choose their own wake up tune

which method is the best way to go ???

thanks
 
Du Dang said:
thanks Fred !!!

i guess i have to make due with wav format

thanks again for helping out,

Du

There are plenty of options for playing mp3 in C#. Do a search on google groups with the term "C# mp3" and you will find all the
info you need. There is even a component written in C# with full source that plays mp3s.
 
Du Dang,

There is also the AudioVideo class in the DirectX 9 SDK that can play MP3
files.

--

Lynn Harrison
SHAMELESS PLUG - Introduction to 3D Game Engine Design (C# & DX9)
www.forums.Apress.com

Michael Culley said:
There are plenty of options for playing mp3 in C#. Do a search on google
groups with the term "C# mp3" and you will find all the
 
Maybe just import the mediaplayer9, and use that to play mp3s. You can hide
the GUI to it if you want.

John
 
Back
Top