play aac file in csharp

To play an AAC audio file in C#, you can use the MediaPlayer class from the Windows Media Player COM API.

First, add a reference to the Interop.WMPLib assembly in your project. You can find it under the COM tab in the Add Reference dialog.

Then, you can create an instance of the MediaPlayer class and call its URL property to load the AAC file, and its controls.play method to start playback.

Here's some sample code to get you started:

main.cs
using WMPLib;

class Program
{
    static void Main(string[] args)
    {
        WindowsMediaPlayer wmp = new WindowsMediaPlayer();
        wmp.URL = "path/to/your/file.aac";
        wmp.controls.play();
    }
}
212 chars
12 lines

Make sure to replace "path/to/your/file.aac" with the actual path to your AAC file. Also, keep in mind that this approach requires Windows Media Player to be installed on the system where your program is running.

related categories

gistlibby LogSnag