programmatically play mp3 files on windows w/

Posted on 2006-04-05
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.
Question by:SweatCoder
    LVL 3

    Expert Comment

    first of all you have to import winmm library:

                public static extern long PlaySound(String lpszName, long hModule, long      dwFlags);

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


    afaik there is no .NET native way to do this.
    LVL 11

    Author Comment

    Your example was wav. Will it work with MP3?
    LVL 48

    Expert Comment

    LVL 48

    Expert Comment

    LVL 48

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Top Freelancers to Complete C# Projects

    Source the talented Expert Exchange community
    for top quality work on your C# projects.

    Hire the best. Collaborate easily. Get quality work.

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now