/// <summary> /// Reloads the currently selected sound. /// </summary> private void ReloadSound() { if (_soundChannel != null) { _soundChannel.Stop(); _soundChannel = null; } if (_sound != null) { _sound.Stop(); _sound = null; } GC.Collect(); SoundFlags flags = 0; if (_streamed == true) { flags |= SoundFlags.Streamed; } if (_positional == true) { flags |= SoundFlags.Positional; } if (fileTreeView.SelectedNode != null && File.Exists(Engine.GlobalInstance.AudioPath + "/" + fileTreeView.SelectedNode.FullPath)) { _sound = AudioManager.LoadSound(Engine.GlobalInstance.AudioPath + "/" + fileTreeView.SelectedNode.FullPath, flags); _soundChannel = _sound.Play(); } SyncronizeWindow(); }
/// <summary> /// Disposes of this class when it is closed. /// </summary> /// <param name="sender">Object that invoked this event.</param> /// <param name="e">Reason why this event was invoked.</param> private void MusicPlayerWindow_FormClosed(object sender, FormClosedEventArgs e) { _soundChannel.Stop(); _soundChannel = null; _sound.Stop(); _sound = null; GC.Collect(); }
public void StopChannel(ScriptThread thread) { ISampleBuffer sound = ((NativeObject)thread.GetObjectParameter(0)).Object as ISampleBuffer; if (sound == null) { DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called StopChannel with an invalid object.", LogAlertLevel.Error); return; } sound.Stop(); }