Playing audio on .NET Core with NetCoreAudio

For well over a decade, .NET Framework was the main software development platform that Microsoft stack programmers were using. As great as it was, it had one significant disadvantage – it could only be ran on Windows. This limitation has prompted Microsoft to release another programming platform, .NET Core, which is intended to eventually replace .NET Framework.

Unlike .NET Framework, .NET Core can run on Linux and Mac as well as Windows. However, as the platform is still very young, it lacks some of the basic functionality that .NET Framework developers learned to take for granted. Until recently, one of these missing pieces of functionality was the ability to play audio.

However, with NetCoreAudio NuGet package, this is no longer an issue.

What is NetCoreAudio

NetCoreAudio is a library with a set of simple controls. It allows you to play, pause, resume and stop audio files from your .NET Core code.

The library works on any operating system supported by .NET Core. Of course, audio plays differently on different platforms. Therefore, each OS supported by .NET Core has its own implementation of audio controls inside NetCoreAudio library.

However, the internals of the library will detects what OS the software is running on and will apply the correct implementation accordingly.

One major advantage of NetCoreAudio over other methods of audio playback on .NET Core is that it doesn’t have any dependencies on third party libraries. Not only that, but it doesn’t require anything other than plain .NET Core to run.

If all you want to do is create a simple background application that is capable of playing audio in the device it is running on, NetCoreAudio NuGet package is all you need.

This is what makes NetCoreAudio a better solution than, for example, inter-operability with Node.js via NodeServices. Launching NPM audio libraries from your .NET Core code will also work, but NodeServices do require the availability of ASP.NET Core components. This would make your application much heavier than it needs to be, especially if you don’t intend to host any of its components over a network.

Likewise, NetCoreAudio is completely free and open-source, unlike some other NuGet packages available out there. Therefore, as well as using it as is, you can modify the code to suite your needs.

This tutorial describes how the library works. You can use this information to make your own variation of it.

Any feedback and contribution is welcome

NetCoreAudio is evolving product. And, to get it to evolve into the right direction, your feedback will be appreciated.

The GitHub page of the project has a section on it where anyone can make comments or raise issues. And you are welcome to do so.

Likewise, any contribution from other developers will be welcome. If you make any changes that would genuinely add value to the library, those will surely be merged into the master branch.

In the meantime, I hope you find this library helpful.