We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

SweatCoder
SweatCoder asked
on
Medium Priority
1,853 Views
Last Modified: 2010-07-27
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.
Comment
Watch Question

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.

Author

Commented:
Your example was wav. Will it work with MP3?
CERTIFIED EXPERT

Commented:
CERTIFIED EXPERT

Commented:
CERTIFIED EXPERT
Commented:

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.