コード例 #1
0
ファイル: AudioEditor.cs プロジェクト: writeescape/ags
 private void StopAnyPlayingSound()
 {
     if (_previewer != null)
     {
         _previewer.Stop();
         _previewer = null;
     }
     lock (_timerLock)
     {
         if (_timer != null)
         {
             _timer.Dispose();
             _timer = null;
         }
     }
 }
コード例 #2
0
ファイル: AudioEditor.cs プロジェクト: onitake/ags
        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;
            }
        }