mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-12-16 04:44:56 +01:00
ready for testing
This commit is contained in:
30
ObservatoryCore/Utils/AudioHandler.cs
Normal file
30
ObservatoryCore/Utils/AudioHandler.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NAudio.Wave;
|
||||
|
||||
namespace Observatory.Utils
|
||||
{
|
||||
internal static class AudioHandler
|
||||
{
|
||||
internal static async Task PlayFile(string filePath)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
using (var file = new AudioFileReader(filePath))
|
||||
using (var output = new WaveOutEvent())
|
||||
{
|
||||
output.Init(file);
|
||||
output.Play();
|
||||
|
||||
while (output.PlaybackState == PlaybackState.Playing)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user