protected override void Destroy() { base.Destroy(); if (IsDisposed) { return; } State = AudioEngineState.Disposed; SoundBase[] notDisposedSoundsArray; lock (notDisposedSounds) { notDisposedSoundsArray = notDisposedSounds.ToArray(); } // Dispose all the sound not disposed yet. foreach (var soundBase in notDisposedSoundsArray) { soundBase.Dispose(); } --nbOfAudioEngineInstances; DestroyImpl(); }
/// <summary> /// Pause the audio engine. That is, pause all the currently playing <see cref="SoundInstanceBase"/>, and block any future play until <see cref="ResumeAudio"/> is called. /// </summary> public void PauseAudio() { if (State != AudioEngineState.Running) { return; } State = AudioEngineState.Paused; PauseAudioPlatformSpecific(); pausedSounds.Clear(); foreach (var sound in notDisposedSounds) { var soundEffect = sound as SoundEffect; if (soundEffect != null) { foreach (var instance in soundEffect.Instances) { if (instance.PlayState == SoundPlayState.Playing) { instance.Pause(); pausedSounds.Add(instance); } } } var soundInstance = sound as SoundInstanceBase; if (soundInstance != null && soundInstance.PlayState == SoundPlayState.Playing) { soundInstance.Pause(); pausedSounds.Add(soundInstance); } } }
/// <summary> /// Resume all audio engine. That is, resume the sounds paused by <see cref="PauseAudio"/>, and re-authorize future calls to play. /// </summary> public void ResumeAudio() { if (State != AudioEngineState.Paused) { return; } State = AudioEngineState.Running; ResumeAudioPlatformSpecific(); foreach (var playableSound in pausedSounds) { if (!playableSound.IsDisposed && playableSound.PlayState == SoundPlayState.Paused) // sounds can have been stopped by user while the audio engine was paused. { playableSound.Play(); } } }
protected override void Destroy() { base.Destroy(); if (IsDisposed) return; State = AudioEngineState.Disposed; SoundBase[] notDisposedSoundsArray; lock (notDisposedSounds) { notDisposedSoundsArray = notDisposedSounds.ToArray(); } // Dispose all the sound not disposed yet. foreach (var soundBase in notDisposedSoundsArray) soundBase.Dispose(); --nbOfAudioEngineInstances; DestroyImpl(); }
/// <summary> /// Resume all audio engine. That is, resume the sounds paused by <see cref="PauseAudio"/>, and re-authorize future calls to play. /// </summary> public void ResumeAudio() { if(State != AudioEngineState.Paused) return; State = AudioEngineState.Running; ResumeAudioPlatformSpecific(); foreach (var playableSound in pausedSounds) { if (!playableSound.IsDisposed && playableSound.PlayState == SoundPlayState.Paused) // sounds can have been stopped by user while the audio engine was paused. playableSound.Play(); } }
/// <summary> /// Pause the audio engine. That is, pause all the currently playing <see cref="SoundInstanceBase"/>, and block any future play until <see cref="ResumeAudio"/> is called. /// </summary> public void PauseAudio() { if(State != AudioEngineState.Running) return; State = AudioEngineState.Paused; PauseAudioPlatformSpecific(); pausedSounds.Clear(); foreach (var sound in notDisposedSounds) { var soundEffect = sound as SoundEffect; if (soundEffect != null) { foreach (var instance in soundEffect.Instances) { if (instance.PlayState == SoundPlayState.Playing) { instance.Pause(); pausedSounds.Add(instance); } } } var soundInstance = sound as SoundInstanceBase; if(soundInstance != null && soundInstance.PlayState == SoundPlayState.Playing) { soundInstance.Pause(); pausedSounds.Add(soundInstance); } } }