private void UpdateCurrentTime() { if (_previewer != null) { _previewer.Poll(); int currentPos = _previewer.GetPositionMs(); int currentLen = _previewer.GetLengthMs(); lblCurrentPosition.Text = string.Format("{0:00}:{1:00} / {2:00}:{3:00}", (currentPos / 1000) / 60, (currentPos / 1000) % 60, (currentLen / 1000) / 60, (currentLen / 1000) % 60); } else { lblCurrentPosition.Text = ""; } }
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; } }