Exemplo n.º 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());
                    }
                }
            }
        }
Exemplo n.º 2
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());
     }
 }