Example #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            string mediaPath = txtMediaPath.Text;

            if (File.Exists(mediaPath) && File.Exists(FFmpegPath))
            {
                Options.LastVideoPath = mediaPath;

                pbProgress.Value   = 0;
                pbProgress.Maximum = Options.ThumbnailCount;
                pbProgress.Visible = true;
                btnStart.Visible   = false;

                new Thread(() =>
                {
                    List <VideoThumbnailInfo> thumbnails = null;

                    try
                    {
                        VideoThumbnailer thumbnailer = new VideoThumbnailer(mediaPath, FFmpegPath, Options);
                        thumbnailer.ProgressChanged += Thumbnailer_ProgressChanged;
                        thumbnails = thumbnailer.TakeThumbnails();
                    }
                    catch (Exception ex)
                    {
                        ex.ShowError();
                    }
                    finally
                    {
                        this.InvokeSafe(() =>
                        {
                            if (thumbnails != null)
                            {
                                OnThumbnailsTaken(thumbnails);
                            }

                            btnStart.Visible   = true;
                            pbProgress.Visible = false;
                        });
                    }
                }).Start();
            }
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            string mediaPath = txtMediaPath.Text;

            if (File.Exists(mediaPath) && File.Exists(FFmpegPath))
            {
                Options.LastVideoPath = mediaPath;

                pbProgress.Value = 0;
                pbProgress.Maximum = Options.ThumbnailCount;
                pbProgress.Visible = true;
                btnStart.Visible = false;

                new Thread(() =>
                {
                    List<VideoThumbnailInfo> thumbnails = null;

                    try
                    {
                        VideoThumbnailer thumbnailer = new VideoThumbnailer(mediaPath, FFmpegPath, Options);
                        thumbnailer.ProgressChanged += Thumbnailer_ProgressChanged;
                        thumbnails = thumbnailer.TakeThumbnails();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "ShareX - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        this.InvokeSafe(() =>
                        {
                            if (thumbnails != null)
                            {
                                OnThumbnailsTaken(thumbnails);
                            }

                            btnStart.Visible = true;
                            pbProgress.Visible = false;
                        });
                    }
                }).Start();
            }
        }
Example #3
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            string mediaPath = txtMediaPath.Text;

            if (File.Exists(mediaPath) && File.Exists(FFmpegPath))
            {
                VideoThumbnailer thumbnailer = new VideoThumbnailer(mediaPath, FFmpegPath, Options);
                thumbnailer.ProgressChanged += Thumbnailer_ProgressChanged;
                pbProgress.Value = 0;
                pbProgress.Maximum = Options.ScreenshotCount;
                pbProgress.Visible = true;
                btnStart.Visible = false;
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += (sender2, e2) => thumbnailer.TakeScreenshots();
                bw.RunWorkerCompleted += (sender3, e3) =>
                {
                    btnStart.Visible = true;
                    pbProgress.Visible = false;
                };
                bw.RunWorkerAsync();
            }
        }
Example #4
0
        private async void btnStart_Click(object sender, EventArgs e)
        {
            string mediaPath = txtMediaPath.Text;

            if (File.Exists(mediaPath) && File.Exists(FFmpegPath))
            {
                Options.LastVideoPath = mediaPath;

                pbProgress.Value   = 0;
                pbProgress.Maximum = Options.ThumbnailCount;
                pbProgress.Visible = true;
                btnStart.Visible   = false;

                List <VideoThumbnailInfo> thumbnails = null;

                await Task.Run(() =>
                {
                    try
                    {
                        VideoThumbnailer thumbnailer = new VideoThumbnailer(FFmpegPath, Options);
                        thumbnailer.ProgressChanged += Thumbnailer_ProgressChanged;
                        thumbnails = thumbnailer.TakeThumbnails(mediaPath);
                    }
                    catch (Exception ex)
                    {
                        ex.ShowError();
                    }
                });

                if (thumbnails != null)
                {
                    OnThumbnailsTaken(thumbnails);
                }

                btnStart.Visible   = true;
                pbProgress.Visible = false;
            }
        }
Example #5
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            string mediaPath = txtMediaPath.Text;

            if (File.Exists(mediaPath) && File.Exists(FFmpegPath))
            {
                VideoThumbnailer thumbnailer = new VideoThumbnailer(mediaPath, FFmpegPath, Options);
                thumbnailer.ProgressChanged += Thumbnailer_ProgressChanged;
                pbProgress.Value = 0;
                pbProgress.Maximum = Options.ScreenshotCount;
                pbProgress.Visible = true;
                btnStart.Visible = false;

                new Thread(() =>
                {
                    List<VideoThumbnailInfo> screenshots = thumbnailer.TakeScreenshots();

                    if (screenshots != null && screenshots.Count > 0)
                    {
                        this.InvokeSafe(() =>
                        {
                            btnStart.Visible = true;
                            pbProgress.Visible = false;

                            if (Options.UploadScreenshots)
                            {
                                screenshots.ForEach(x => OnUploadRequested(x.Filepath));
                            }
                        });
                    }
                }).Start();
            }
        }