Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2008

Tip: Looking for answers? Try searching our database.

how to play MP3 files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 08 Mar 2008 10:45 GMT
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
TAB - 24 Mar 2008 15:17 GMT
//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();
           }

   }
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.