Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to play MP3 files

Reply
Thread Tools

how to play MP3 files

 
 
Andrew
Guest
Posts: n/a
 
      03-08-2008
Hi,

Sorry for crosspost.

I need to play MP3 files from my .NET 2.0 SP1 C# WinForm app.

I tried referencing Microsoft.DirectX.AudioVideoPlayback; and creating Audio class for playback. But I get the following error which is beyod my ability to comprehend.

[
DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.290 2.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
]

How do I do this. Please help.

- Andrew
 
Reply With Quote
 
 
 
 
TAB
Guest
Posts: n/a
 
      03-24-2008
//Hi, I am using this for playing mp3 and wav. I think I found the example
at Codeproject.com
//Use

Player play = new Player();
play.Open(filename);
play.Play(false); //true for repeat, false for once;
play.Close(); // to stop

//To use the MCI Functions we have to import the winmm.dll.
//Then you go to the MSDN look up a command and its party time.
public class Player
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand,
StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);

private string Pcommand;
private bool isOpen;

public Player()
{
}

public void Close()
{
Pcommand = "close MediaFile";
mciSendString(Pcommand, null, 0, IntPtr.Zero);
isOpen = false;
}

public void Open(string sFileName)
{
Pcommand = "open \"" + sFileName + "\" type mpegvideo alias
MediaFile";
mciSendString(Pcommand, null, 0, IntPtr.Zero);
isOpen = true;
}

public void Play(bool loop)
{
if (isOpen)
{
Pcommand = "play MediaFile";
if (loop)
Pcommand += " REPEAT";
mciSendString(Pcommand, null, 0, IntPtr.Zero);
}
}
// Returns the current status player: playing,paused,stopped
etc.
public string Status()
{
int i = 128;
System.Text.StringBuilder stringBuilder = new
System.Text.StringBuilder(i);
mciSendString("status MediaFile mode", stringBuilder, 128,
IntPtr.Zero);
return stringBuilder.ToString();
}

}
"Andrew" <(E-Mail Removed)> skrev i meddelandet
news:(E-Mail Removed)...
Hi,

Sorry for crosspost.

I need to play MP3 files from my .NET 2.0 SP1 C# WinForm app.

I tried referencing Microsoft.DirectX.AudioVideoPlayback; and creating Audio
class for playback. But I get the following error which is beyod my ability
to comprehend.

[
DLL
'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.290 2.0__31bf3856ad364e35\Microsoft.DirectX.dll'
is attempting managed execution inside OS Loader lock. Do not attempt to run
managed code inside a DllMain or image initialization function since doing
so can cause the application to hang.
]

How do I do this. Please help.

- Andrew

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
3GP to MP3 Convert 3GP to MP3 using 3GP MP3 Converter music-fan DVD Video 0 12-24-2009 04:58 AM
Saving MP3 files to CD as MP3 files Mighty Magpie Computer Information 3 04-07-2008 03:50 PM
play mp3 files from python Adam Endicott Python 9 10-28-2003 05:32 AM
Mp3-player - how to play an mp3? Asle Frantzen C++ 5 07-22-2003 07:09 AM



Advertisments