Play mp3 or wmv audio files in .net

You can play system sound in .net with the help of SystemSound class. And you can also play wav audio file from the .net application by using SoundPlayer class.
But when you need to play mp3 or wmv audio files, you will find that there is no any method to play those formats. The easiest way to go is to let the shell do it for you: see this


The following example demonstrates how to play the audio file in C# and


    Private Sub playAudio()
        Dim path As String = "path to the audio file"
        Dim info As ProcessStar Info = New ProcessStartInfo(path)
        info.UseShellExecute = True
    End Sub


   private void PlayAudio()
            string path = "path to the audio file";
            System.Diagnostics.ProcessStartInfo info =
                new System.Diagnostics.ProcessStartInfo() { FileName = path, UseShellExecute = true };

Simple we are using System.Diagnostics.ProcessStartInfo inheritable class and process class to play the file.
From the above we set UseShellExecute property to true to use the shell when starting the process; otherwise, the process is created directly from the executable file. The default is true.