Created
March 18, 2021 19:33
-
-
Save PieroCastillo/93cab159090016346b638753c2cdb10e to your computer and use it in GitHub Desktop.
Minimal Program using SharpAudio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Threading; | |
using SharpAudio.Codec; | |
namespace SharpAudio.Sample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var engine = AudioEngine.CreateDefault(); | |
string path = "the path of the mp3 file"; | |
if (engine == null) | |
{ | |
Console.WriteLine("Failed to create an audio backend!"); | |
return; | |
} | |
if(!File.Exists(path)) | |
{ | |
Console.WriteLine("The file does not exist."); | |
return; | |
} | |
else | |
{ | |
Console.WriteLine("The file exists."); | |
} | |
var soundStream = new SoundStream(File.OpenRead(path), engine); | |
soundStream.Volume = 5f; | |
Console.WriteLine("Loaded Correctly"); | |
soundStream.Play(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment