Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1784
  • Last Modified:

programmatically play mp3 files on windows w/C#.net

I'm looking for a simple, programmatic way to play brief (5 seconds or less) mp3 files. If possible, I'd like to avoid having to use 3rd-party commercial apps and tap into their API, though I wouldn't mind tapping into Windows Media Player if that's my only option. If there's a free 3rd party component that I could ship with my app, that would be ideal. Or if there's a way for .NET to natively do this, that would be ideal as well.

Looking for (1) Which I should use and (2) Basic sample code usage.
0
SweatCoder
Asked:
SweatCoder
  • 3
1 Solution
 
osmantemizCommented:
first of all you have to import winmm library:

            [DllImport("winmm.dll")]
            public static extern long PlaySound(String lpszName, long hModule, long      dwFlags);

then you can use PlaySound method whenever you want to play sounds...

                PlaySound("msg.wav",0,0);

afaik there is no .NET native way to do this.
0
 
SweatCoderAuthor Commented:
Your example was wav. Will it work with MP3?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now