private void StopAnyPlayingSound() { if (_previewer != null) { _previewer.Stop(); _previewer = null; } lock (_timerLock) { if (_timer != null) { _timer.Dispose(); _timer = null; } } }
private void StopAnyPlayingSound() { if (_previewer != null) { _previewer.Stop(); _previewer = null; } lock (_timerLock) { if (_timer != null) { _timer.Dispose(); _timer = null; } } }
private void btnPlay_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { if (this.SelectedClip.FileType == AudioClipFileType.MIDI) { _previewer = new MidiPlayer(); } else { _previewer = new IrrklangPlayer(); } _previewer.PlayFinished += new PlayFinishedHandler(_previewer_PlayFinished); _paused = false; _timer = new Timer(); _timer.Interval = 900; _timer.Tick += new EventHandler(_timer_Tick); _timer.Start(); if (_previewer.Play(this.SelectedClip)) { UpdateCurrentTime(); btnPlay.Enabled = false; btnPause.Enabled = true; btnStop.Enabled = true; } else { Factory.GUIController.ShowMessage("Unable to play the sound. The file format may not be supported by the AGS Editor.", MessageBoxIcon.Warning); } } finally { Cursor.Current = Cursors.Default; } }
private void btnPlay_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { if (this.SelectedClip.FileType == AudioClipFileType.MIDI) { _previewer = new MidiPlayer(); } else { _previewer = new IrrklangPlayer(); } _previewer.PlayFinished += new PlayFinishedHandler(_previewer_PlayFinished); _paused = false; _timer = new Timer(); _timer.Interval = 900; _timer.Tick += new EventHandler(_timer_Tick); _timer.Start(); if (_previewer.Play(this.SelectedClip)) { UpdateCurrentTime(); btnPlay.Enabled = false; btnPause.Enabled = true; btnStop.Enabled = true; } else { Factory.GUIController.ShowMessage("Unable to play the sound. The file format may not be supported by the AGS Editor.", MessageBoxIcon.Warning); } } finally { Cursor.Current = Cursors.Default; } }
private void SetupForNewItem(object selectedItem) { lock (_timerLock) { if (_timer != null) { _timer.Dispose(); _timer = null; } } if (_previewer != null) { _previewer.Stop(); _previewer.Dispose(); } grpAudioClip.Visible = false; grpAudioType.Visible = false; grpFolder.Visible = false; if (selectedItem is AudioClip) { lblSoundName.Text = "Audio Clip: " + ((AudioClip)selectedItem).ScriptName; lblCurrentPosition.Text = "00:00"; lblClipLength.Text = "/ 00:00"; try { if (this.SelectedClip.FileType == AudioClipFileType.MIDI) { _previewer = new MidiPlayer(this.SelectedClip); } else { _previewer = new IrrklangPlayer(this.SelectedClip); } } catch (AGSEditorException ex) { string message = ex.Message; Factory.GUIController.ShowMessage(message, MessageBoxIcon.Warning); btnPlay.Enabled = false; } if (_previewer != null) { _previewer.PlayFinished += new PlayFinishedHandler(_previewer_PlayFinished); btnPlay.Enabled = true; grpAudioClip.Visible = true; int length = _previewer.GetLengthMs(); lblClipLength.Text = string.Format("/ {0:00}:{1:00}", (length / 1000) / 60, (length / 1000) % 60); } } else if (selectedItem is AudioClipFolder) { lblFolderTitle.Text = "Folder: " + ((AudioClipFolder)selectedItem).Name; grpFolder.Visible = true; } else if (selectedItem is AudioClipType) { lblAudioTypeTitle.Text = "Audio Type: " + ((AudioClipType)selectedItem).Name; grpAudioType.Visible = true; } }