Play Sounds RRS feed

  • Question

  • Hi! I know I am a newbie in C# (trying to port over from VB), and I was wondering how to play a sound without usuing the Windows Media Player Control (for sound effects). Thanks for any help

    In VB this would be"FILEPATH")

    Saturday, August 11, 2012 4:56 PM


  • With Windows Forms easiest way to play sound is use SoundPlayer class. Easiest way to use it is just pass path to the audio file and call Play method.

    If instead you are using WPF, then easiest way to play sound is use MediaElement class.

    void PlayMedia(string pathToMedia)
        SoundPlayer player = new SoundPlayer(pathToMedia);

    Saturday, August 11, 2012 5:34 PM

All replies