i done a code for playing a .wav through my appln.now i want to play a mp3 file through can anyone help to come around that. herer i have .net framework 1.1 only
+1
A:
You can try NAudio. Otherwise you may consider to use a native library using Interop.
weismat
2009-07-04 07:41:42
NAudio is compiled against 2.0, although you may find you can recompile the bits you need against 1.1. There are simpler ways (such as sending MCI string) if you simply need to be able to start and stop.
Mark Heath
2009-07-04 09:29:30
+3
A:
if you have .NET framework 1.1. only, probably your best approach is to use a P/Invoke wrapper for mciSendCommand
[DllImport("winmm.dll")]
private static extern long mciSendString(
string strCommand, StringBuilder returnString,
int returnBufferLength, IntPtr callback);
void PlayFile(string mp3FileName)
{
string deviceType = "MPEGVideo";
string fileName = mp3FileName;
string alias = "MyMp3File";
string playCommand = string.Format("open \"{0}\" type {1} alias {2}",
fileName, deviceType, alias);
mciSendString(playCommand, null, 0, IntPtr.Zero);
playCommand = string.Format("play {0} from 0", alias);
mciSendString(playCommand, null, 0, IntPtr.Zero);
// send these when you are finished
// playCommand = "stop MyMp3File";
// playCommand = "close MyMp3File";
}
Mark Heath
2009-07-04 09:25:21
+1
A:
I'd suggest using DirectShow - the RenderFile API is extremely simple. This site appears to show a managed wrapper for DShow (caveat programmer, I've not used it).
Edit to add: Personally I'd stay away from the MCI APIs if at all possible - they're extremely old APIs and they're not particularly reliable.
Larry Osterman
2009-07-05 06:42:27
Fair enough, I don't use mci APIs myself. But though the RenderFile API call itself is simple, the sheer amount of COM interfaces that have to have .NET wrappers created before you can get started is daunting for most developers, especially if all you want to do is play an MP3 File. Still the link to the managed wrapper looks like it would be very helpful. +1 from me.
Mark Heath
2009-07-05 20:24:29