diff options
| author | Michael <[email protected]> | 2017-04-16 08:17:27 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-16 08:17:27 -0400 |
| commit | 0bc6b155127b0c03645947e2eec3574e0fc03029 (patch) | |
| tree | 6608405c3e48c7a9d420633752c3a1e0a5ce6c78 /ShiftOS_TheReturn | |
| parent | 112c05cb5e460e277ea93604ba1bb5d6ea010f0a (diff) | |
| download | shiftos_thereturn-0bc6b155127b0c03645947e2eec3574e0fc03029.tar.gz shiftos_thereturn-0bc6b155127b0c03645947e2eec3574e0fc03029.tar.bz2 shiftos_thereturn-0bc6b155127b0c03645947e2eec3574e0fc03029.zip | |
Document the audio manager
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/AudioManager.cs | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 1dd2a8b..82b7000 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -43,6 +43,9 @@ namespace ShiftOS.Engine private static IAudioProvider _provider = null; private static bool _running = true; + /// <summary> + /// Stops the current sound if one is playing and disposes of the sound. + /// </summary> public static void Stop() { _out?.Stop(); @@ -50,17 +53,32 @@ namespace ShiftOS.Engine _out?.Dispose(); } + /// <summary> + /// Initiates this engine module using an <see cref="IAudioProvider"/> as a backend for selecting background soundtrack as well as the volume level for the sound. + /// </summary> + /// <param name="_p">A background soundtrack and volume provider.</param> + /// <exception cref="ArgumentNullException">Thrown if <paramref name="_p"/> is null.</exception> public static void Init(IAudioProvider _p) { + if (_p == null) + throw new ArgumentNullException("_p"); _provider = _p; } + /// <summary> + /// Sets the volume of the audio system. + /// </summary> + /// <param name="volume">The volume to use, from 0 to 1.</param> public static void SetVolume(float volume) { _provider.Volume = volume; //persist between songs _out.Volume = volume; } + /// <summary> + /// Plays a specified sound file. + /// </summary> + /// <param name="file">The file to play.</param> public static void Play(string file) { try @@ -74,6 +92,10 @@ namespace ShiftOS.Engine catch { } } + /// <summary> + /// Writes the data in the specified <see cref="Stream"/> to a file, and plays it as a sound file. + /// </summary> + /// <param name="str">The stream to read from.</param> public static void PlayStream(Stream str) { var bytes = new byte[str.Length]; @@ -86,14 +108,6 @@ namespace ShiftOS.Engine ShiftOS.Engine.AudioManager.Play("snd.wav"); } - - internal static void Kill() - { - _running = false; - _out.Stop(); - _out.Dispose(); - _reader.Dispose(); - } } public interface IAudioProvider |
