コード例 #1
0
ファイル: FormPlayer.cs プロジェクト: VPKSoft/vamp
        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);
            }
        }