using System; namespace FlowScope.Audio { public sealed class AudioHandle : IAudioHandle { private readonly Func _isPlaying; private readonly Action _stop; internal AudioHandle(Func isPlaying, Action stop) { _isPlaying = isPlaying ?? throw new ArgumentNullException(nameof(isPlaying)); _stop = stop ?? throw new ArgumentNullException(nameof(stop)); } public bool IsPlaying => _isPlaying(); public void Stop(float fadeOut = 0f) { _stop(fadeOut); } internal static AudioHandle Stopped { get; } = new AudioHandle(() => false, _ => { }); } }