public void PlayAndWait(float volume) { ISound sound = AudioClip.Play(volume); OnSoundStarted.Invoke(sound); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); Task.Run(async() => await sound.Completed).Wait(); OnSoundCompleted.Invoke(sound); }
public ISound Play(float volume, bool shouldLoop = false) { ISound sound = AudioClip.Play(volume, shouldLoop); OnSoundStarted.Invoke(sound); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); sound.Completed.ContinueWith(_ => OnSoundCompleted?.Invoke(sound)); return(sound); }
public void PlayAndWait(ISoundProperties properties = null) { ISound sound = AudioClip.Play(false, properties); OnSoundStarted.Invoke(sound); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); Task.Run(async() => await sound.Completed).Wait(); OnSoundCompleted.Invoke(sound); }
public ISound Play(bool shouldLoop = false, ISoundProperties properties = null) { ISound sound = AudioClip.Play(shouldLoop, properties); OnSoundStarted.Invoke(sound); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); sound.Completed.ContinueWith(_ => OnSoundCompleted?.Invoke(sound)); return(sound); }
private ISound playSound(float volume, float pitch, float panning, IConcurrentHashSet <string> tags, bool looping = false) { //Debug.WriteLine("Playing Sound: " + ID); int source = getSource(); ALSound sound = new ALSound(source, Duration, volume, pitch, looping, panning, tags, _errors, _backend); _playingSounds.Add(sound); OnSoundStarted.Invoke(sound); sound.Play(_buffer.Value); sound.Completed.ContinueWith(_ => { _system.ReleaseSource(source); _playingSounds.Remove(sound); OnSoundCompleted.Invoke(sound); }); return(sound); }