Playing AAC (.m4a) Files

Jan 9, 2013 at 5:37 AM

Does naudio have any plans to support playing AAC (.m4a) files? Right now when you try to load one into AudioFileReader

fileWaveStream = new AudioFileReader(@"c:\music\test.m4a");

Jan 9, 2013 at 5:46 AM

The issue is with CreateReaderStream(string fileName) in audioFileReader it doesn't look for anything other than ".wav",".mp3", and ".aiff". I'm I just stupid and missing something and should be using another FileReader? 

Coordinator
Jan 11, 2013 at 10:18 PM

You will be able to play AAC in NAudio 1.7 using the MediaFoundationReader so long as you are using Windows 7 and above. You can try this out by building the latest code or getting a prerelease from NuGet if you are interested.

Mark

May 23 at 12:03 AM
I have a whole house jukebox application running on Windows XP. I just updated it from NAudio 1.5 to NAudio 1.7 and so far it is mostly working.
Question 1 - The waveOutDevice.PlaybackStopped event changed signature in NAudio 1.6, but that was easily found and fixed. But now, if I manually Stop playback, the event is properly detected, but if the song reaches End-Of-File, the event is not raised/detected ( and the application restarts). In the past we had to use mainOutputStream.PadWithZeroes = False to ensure we got an event on EOF. Is there a new trick?

Question 2 - I tried to play an AAC file and got an exception (of course - you said "Windows 7 and above"). My question is, should I use the MediaFoundationReader for WMA files? I.E. is it just the AAC files that need Windows 7, or is it the MediaFoundationReader?

Thanks,
Jake
May 23 at 4:44 AM
It turns out that question #1 is a regression issue. The same problem, and the same fix, was discussed in thisthis thread. I made the same changes and it is working now.

Question #2 remains.

Jake
Coordinator
May 23 at 1:53 PM
MediaFoundationReader will be able to play WMA. NAudio does also have a separate WMA assembly that you could use if Windows XP support is needed with a class called WmaFileReader.

It's a pain that the SyncContext in ASP.NET doesn't work. I might have to make it injectable. I wasn't really expecting too many people to be playing audio on a web server.
May 23 at 4:12 PM
markheath wrote:
It's a pain that the SyncContext in ASP.NET doesn't work. I might have to make it injectable. I wasn't really expecting too many people to be playing audio on a web server.
If I'm the only one using that class in a Windows Service (i.e. not in a Windows Form), then I could look into the issue and perhaps debug it further. Does your roadmap includes a future for WaveOutEvent? If so, and if you want me to look into it, just let me know where to look, for a starting point to get up to speed on that portion of the code.

Jake