dotnet faqs:
//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" <nospam@tome.com> skrev i meddelandet news:e1gvZmQgIHA.5088@TK2MSFTNGP02.phx.gbl... 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.2902.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
Don't see what you're looking for? Try a search.
|