Пример #1
0
        /// <summary>
        /// Handles the Click event of the playToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev05, 2007-10-11</remarks>
        private void playToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (((Control)contextMenuStripMedia.Tag).Name.Contains("Audio"))
            {
                try
                {
                    IAudio audioobject = ((Control)contextMenuStripMedia.Tag).Tag as IAudio;
                    if (audioobject != null)
                    {
                        AudioPlayer player = new AudioPlayer();
                        player.Play(audioobject.Filename, true);
                    }
                }
                catch (Exception exp)
                {
                    System.Windows.Forms.MessageBox.Show(Properties.Resources.AUDIOPLAYER_CRASHED_TEXT, Properties.Resources.AUDIOPLAYER_CRASHED_CAPTION,
                            System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    System.Diagnostics.Trace.WriteLine("PlayToolStrip Audio Player crashed: " + exp.ToString());
                }
            }
            else //Video
            {
                PictureBox selectedpicturebox = ((Control)contextMenuStripMedia.Tag).Name.Contains("Answer") ? pictureBoxAnswer : pictureBoxQuestion;
                VideoPlayer playing = PlayingVideo(selectedpicturebox);
                if (playing != null)
                {
                    playing.Stop();
                }
                else
                {
                    try
                    {
                        IVideo videoobject = ((Control)contextMenuStripMedia.Tag).Tag as IVideo;
                        if (videoobject != null)
                        {
                            VideoPlayer video = new VideoPlayer(selectedpicturebox);
                            video.Ending += new EventHandler(Video_Ending);
                            video.Stopping += new EventHandler(Video_Ending);
                            video.Play(videoobject.Filename);

                            playingVideos.Add(video);
                        }
                    }
                    catch (Exception exp)
                    {
                        System.Diagnostics.Trace.WriteLine("PlayToolStrip Video Player crashed: " + exp.ToString());
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Handles the Ending event of the player control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev02, 2008-01-11</remarks>
 private void player_Ending(object sender, EventArgs e)
 {
     buttonPlay.Image = Resources.mediaPlaybackStart;
     buttonChange.Enabled = buttonDelete.Enabled = dictionary.CanModify;
     player = null;
 }
Пример #3
0
        /// <summary>
        /// Handles the Click event of the buttonPlay control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev05, 2007-12-06</remarks>
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            try
            {
                if (player == null)
                {
                    player = new AudioPlayer();
                    player.Ending += new EventHandler(player_Ending);
                }

                if (!player.IsPlaying)
                {
                    buttonBrowse.Enabled = false;
                    buttonRecord.Enabled = false;
                    buttonRemove.Enabled = false;

                    buttonPlay.Image = Resources.mediaPlaybackStop;
                    buttonPlay.Text = Resources.AUDIO_STOP;

                    player.Play(Path);
                }
                else
                {
                    player.Stop();
                    player_Ending(player, EventArgs.Empty);
                }
            }
            catch (Exception exp)
            {
                System.Windows.Forms.MessageBox.Show(Properties.Resources.AUDIOPLAYER_CRASHED_TEXT, Properties.Resources.AUDIOPLAYER_CRASHED_CAPTION,
                            System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);

                System.Diagnostics.Trace.WriteLine("AudioDialog Player crashed: " + exp.ToString());
            }
        }
Пример #4
0
 /// <summary>
 /// Handles the Click event of the buttonPlay control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev02, 2008-01-10</remarks>
 private void buttonPlay_Click(object sender, EventArgs e)
 {
     if (player == null && SelectedSoundID.HasValue &&
         commentarySounds.ContainsKey(SelectedSoundID.Value) && commentarySounds[SelectedSoundID.Value].Filename != string.Empty)
     {
         player = new AudioPlayer();
         player.Ending += new EventHandler(player_Ending);
         player.Play(commentarySounds[SelectedSoundID.Value].Filename, true);
         buttonPlay.Image = Resources.mediaPlaybackStop;
         buttonChange.Enabled = buttonDelete.Enabled = false;
     }
     else
     {
         player.Stop();
         player_Ending(null, new EventArgs());
     }
 }
Пример #5
0
 /// <summary>
 /// Handles the FormClosing event of the AudioDialog control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.Forms.FormClosingEventArgs"/> instance containing the event data.</param>
 /// <remarks>Documented by Dev02, 2008-02-29</remarks>
 private void AudioDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (player != null)
     {
         try
         {
             // [ML-1181] Can't play MIDI-Files
             player.Stop();  // Stop the current audio played
             player.Dispose();   // and clean-up
         }
         catch { }
         player = null;
     }
     if (recorder.Recording)
     {
         recorder.StopRecording();
     }
 }