A simple Audio Library for playing audio in Console Projects. This library is built on top of ManagedBass. It starts a background thread which manages the disposal of audio automagically.
You can add as a NuGet package:
dotnet add package CaptainCoder.SimpleAudio
using CaptainCoder.SimpleAudioLib;
SimpleAudio.PlayFile("Victory.mp3");
// Doesn't block, you can keep doing things.
using CaptainCoder.SimpleAudioLib;
SimpleAudio.PlayURL("https://github.com/jcollard/SimpleAudioLib/blob/main/audio/Victory.mp3?raw=true");
// Doesn't block, you can keep doing things.
If the main thread exits, the audio will be disposed of automatically. To wait for audio to finish before continuing run:
using CaptainCoder.SimpleAudioLib;
SimpleAudio.PlayURL("https://github.com/jcollard/SimpleAudioLib/blob/main/audio/Victory.mp3?raw=true");
SimpleAudio.WaitForAllAudio();
You can stop all currently playing audio:
using CaptainCoder.SimpleAudioLib;
SimpleAudio.PlayURL("https://github.com/jcollard/SimpleAudioLib/blob/main/audio/Victory.mp3?raw=true");
SimpleAudio.StopAllAudio();