This project has moved and is read-only. For the latest updates, please go here.

Naudio on Mono

May 11, 2013 at 7:29 PM
I am using building a c# application that plays music. I have heard about this project a lot and it seems like a good choice. I am curious to see if this runs cross platform on mono. If so, what are the limitations? I have heard that it can't play mp3 cross platform, but is their any workarounds? Thank you!
May 12, 2013 at 8:26 AM
It depends on what you call cross platform. Running your application using mono on a Windows workstation wouldn't be a problem. NAudio depends heavily on p-invoke calls to the underlying operating system (Windows). So running your application on a different operating system, e.g. Linux, will result in no audio at all.
There will be parts of NAudio that work. e.g. wavestreams for reading information from wave files doesn't rely on native OS calls.

I would suggest to create an abstraction of playing audio files in your application, so you can choose the appropriate audio framework based on the platform you are running on. And then use NAudio for playing on a Windows playform.
May 12, 2013 at 3:01 PM
Thanks for the advice. So you recommend a different library for each platform?
May 12, 2013 at 3:29 PM
probably the best idea if you like the NAudio structure is to create a new implementation of IWavePlayer for Mono that P/Invokes into Linux audio playback APIs (I'm not a mono or Linux expert so I have no idea how hard that would be). The same would apply for any audio format conversion. Instead of WaveFormatConversionStream (which uses the Windows ACM API), you'd need something that hooks into codecs available for Linux.