diff options
| author | Michael <[email protected]> | 2017-04-15 15:08:21 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-15 15:08:21 -0400 |
| commit | 0807e04881336ef51b1c473d2e61d344c8bef113 (patch) | |
| tree | ef95db0c591c66e78a901a4d23103c6e83963f91 /ShiftOS_TheReturn | |
| parent | 51050a02d4d5eff361cfa697eeba777ddafa085a (diff) | |
| download | shiftos_thereturn-0807e04881336ef51b1c473d2e61d344c8bef113.tar.gz shiftos_thereturn-0807e04881336ef51b1c473d2e61d344c8bef113.tar.bz2 shiftos_thereturn-0807e04881336ef51b1c473d2e61d344c8bef113.zip | |
Add sounds to pong and fix audio bugs
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/AudioManager.cs | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 54ee1f1..1dd2a8b 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -26,6 +26,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading; @@ -62,20 +63,29 @@ namespace ShiftOS.Engine public static void Play(string file) { - new Thread(() => + try { - try - { - _reader = new AudioFileReader(file); - _out = new WaveOut(); - _out.Init(_reader); - _out.Volume = _provider.Volume; - _out.Play(); - } - catch { } - }).Start(); + _reader = new AudioFileReader(file); + _out = new WaveOut(); + _out.Init(_reader); + _out.Volume = _provider.Volume; + _out.Play(); + } + catch { } } + public static void PlayStream(Stream str) + { + var bytes = new byte[str.Length]; + str.Read(bytes, 0, bytes.Length); + ShiftOS.Engine.AudioManager.Stop(); + if (File.Exists("snd.wav")) + File.Delete("snd.wav"); + File.WriteAllBytes("snd.wav", bytes); + + ShiftOS.Engine.AudioManager.Play("snd.wav"); + + } internal static void Kill() { |
