Ejemplo n.º 1
0
        /// <summary>
        /// Shows the dialog if necessary and returns a new playback position in milliseconds.
        /// </summary>
        /// <param name="videoFileStatistic">A VideoFileStatistic class instance to be used to initialize the dialog from.</param>
        /// <returns>A playback position in milliseconds.</returns>
        public static long Execute(VideoFileStatistic videoFileStatistic)
        {
            // if the saved playback position is zero or more than 99 percent was played last time just return 0..
            // decrease 5 seconds from the position for "a human/a media consuming entity" to catch/remember something of the previous moment..
            if (videoFileStatistic.Position - 5000 <= 0 || videoFileStatistic.PlayBackPercentage >= 99.0)
            {
                return(0);
            }

            // the given VideoFileStatistic class instance requires the dialog to be shown.. so create a SelectPlaybackPositionDialog..
            FormDialogSelectPlaybackPosition selectPlaybackPositionDialog = new FormDialogSelectPlaybackPosition();

            // a N value of a milliseconds to ticks (100-nanosecond units) = multiply by 100 * 100..
            TimeSpan timeSpan = new TimeSpan(videoFileStatistic.Position * 100 * 100);

            // give the statistics for the form..
            // .. and decrease 5 seconds from the position for "a human/a media consuming entity" to catch/remember something of the previous moment..
            selectPlaybackPositionDialog.Tag = videoFileStatistic.Position - 5000;

            // set the playback position for to the button "Continue playback from position N"..
            selectPlaybackPositionDialog.btContinue.Text =
                string.Format(selectPlaybackPositionDialog.btContinue.Tag.ToString(), timeSpan.ToString(@"hh\:mm\:ss"));

            // show the dialog..
            selectPlaybackPositionDialog.ShowDialog();

            // return the playback position the user selected by
            return(selectPlaybackPositionDialog.returnPlaybackPosition);
        }
Ejemplo n.º 2
0
        volatile bool statisticsLoaded        = false; // to indicate that the video statistics were loaded from the database
                                                       // END: These are valid parameters for the VlcControl.SetMedia() method overloads..


        /// <summary>
        /// Initialize the VlcControl with a FileInfo class instance.
        /// </summary>
        /// <param name="file">A FileInfo class instance to initialize the VlcControl with.</param>
        /// <param name="formPlayer">An instance of the FormPlayer class if one was created.</param>
        /// <param name="options">These are "command line arguments" given to the VlcControl as with the VLC Media Player.</param>
        /// <returns>True if the VlcControl.SetMedia() call was successful, otherwise false (an exception occurred).</returns>
        public static bool InitPlayerForm(FileInfo file, out FormPlayer formPlayer, params string[] options)
        {
            try
            {
                // create a new instance of the FormPlayer form..
                FormPlayer frm = new FormPlayer
                {
                    // set the form's statistic field's value with value gotten
                    // from the database with the file's full name..
                    statistic = Database.GetStatistic(file.FullName)
                };

                // execute a playback dialog if the video was not watched to the end..
                long position = FormDialogSelectPlaybackPosition.Execute(frm.statistic);
                frm.statistic.Position = position; // give a playback position to the video playback form..
                frm.statisticsLoaded   = true;     // indicate to the form that the video file statistics have been loaded..

                frm.options = options;
                frm.file    = file;
                formPlayer  = frm; // set the out parameter's value..
                frm.Show();
                return(true);
            }
            catch (Exception ex)
            {
                // log the exception..
                ExceptionLogger.LogError(ex);

                formPlayer = null; // set the out parameter's value..
                return(false);
            }
        }