private void OpenVideo(string fileName) { if (File.Exists(fileName)) { timer1.Stop(); timerProgressBarRefresh.Stop(); VideoFileName = fileName; var fi = new FileInfo(fileName); if (fi.Length < 1000) { return; } if (MediaPlayerStart.VideoPlayer != null) { MediaPlayerStart.Pause(); MediaPlayerStart.VideoPlayer.DisposeVideoPlayer(); } if (MediaPlayerEnd.VideoPlayer != null) { MediaPlayerEnd.Pause(); MediaPlayerEnd.VideoPlayer.DisposeVideoPlayer(); } VideoInfo videoInfo = ShowVideoInfo(fileName); UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, MediaPlayerStart, VideoStartLoaded, VideoStartEnded); } }
private void Timer1Tick(object sender, EventArgs e) { if (MediaPlayerStart != null) { if (!MediaPlayerStart.IsPaused) { MediaPlayerStart.RefreshProgressBar(); if (_startStopPosition >= 0 && MediaPlayerStart.CurrentPosition > _startStopPosition) { MediaPlayerStart.Pause(); MediaPlayerStart.CurrentPosition = _startGoBackPosition; _startStopPosition = -1; } UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerStart); } if (!MediaPlayerEnd.IsPaused) { MediaPlayerEnd.RefreshProgressBar(); if (_endStopPosition >= 0 && MediaPlayerEnd.CurrentPosition > _endStopPosition) { MediaPlayerEnd.Pause(); MediaPlayerEnd.CurrentPosition = _endGoBackPosition; _endStopPosition = -1; } UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerEnd); } } }
private void FormVisualSync_FormClosing(object sender, FormClosingEventArgs e) { _timerHideSyncLabel.Stop(); labelSyncDone.Text = string.Empty; timer1.Stop(); timerProgressBarRefresh.Stop(); if (MediaPlayerStart != null) { MediaPlayerStart.Pause(); } if (MediaPlayerEnd != null) { MediaPlayerEnd.Pause(); } bool change = false; for (int i = 0; i < _paragraphs.Count; i++) { if (_paragraphs[i].ToString() != _originalSubtitle.Paragraphs[i].ToString()) { change = true; break; } } if (!change) { DialogResult = DialogResult.Cancel; return; } DialogResult dr; if (DialogResult == DialogResult.OK) { dr = DialogResult.Yes; } else { dr = MessageBox.Show(_language.KeepChangesMessage, _language.KeepChangesTitle, MessageBoxButtons.YesNoCancel); } if (dr == DialogResult.Cancel) { e.Cancel = true; timer1.Start(); timerProgressBarRefresh.Start(); } else if (dr == DialogResult.Yes) { DialogResult = DialogResult.OK; } else { DialogResult = DialogResult.Cancel; } }
private void OpenVideo(string fileName) { if (File.Exists(fileName)) { timer1.Stop(); timerProgressBarRefresh.Stop(); VideoFileName = fileName; var fi = new FileInfo(fileName); if (fi.Length < 1000) { return; } if (MediaPlayerStart.VideoPlayer != null) { MediaPlayerStart.Pause(); MediaPlayerStart.VideoPlayer.DisposeVideoPlayer(); } if (MediaPlayerEnd.VideoPlayer != null) { MediaPlayerEnd.Pause(); MediaPlayerEnd.VideoPlayer.DisposeVideoPlayer(); } VideoInfo videoInfo = ShowVideoInfo(fileName); // be sure to match frames with movie if (_inputSubtitle.WasLoadedWithFrameNumbers) // frame based subtitles like MicroDVD { if (Math.Abs(_videoInfo.FramesPerSecond - _oldFrameRate) > 0.02) { _inputSubtitle.CalculateTimeCodesFromFrameNumbers(_videoInfo.FramesPerSecond); LoadAndShowOriginalSubtitle(); FrameRateChanged = true; } } if (_inputAlternateSubtitle != null && _inputAlternateSubtitle.WasLoadedWithFrameNumbers) // frame based subtitles like MicroDVD { if (Math.Abs(_videoInfo.FramesPerSecond - _oldFrameRate) > 0.02) { _inputAlternateSubtitle.CalculateTimeCodesFromFrameNumbers(_videoInfo.FramesPerSecond); LoadAndShowOriginalSubtitle(); FrameRateChanged = true; } } UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, MediaPlayerStart, VideoStartLoaded, VideoStartEnded); } }
private void VideoEndLoaded(object sender, EventArgs e) { MediaPlayerEnd.Pause(); GotoSubtitlePosition(MediaPlayerEnd); _endGoBackPosition = MediaPlayerEnd.CurrentPosition; _endStopPosition = _endGoBackPosition + 0.1; MediaPlayerEnd.Play(); if (AudioTrackNumber > -1 && MediaPlayerEnd.VideoPlayer is LibVlcDynamic) { var libVlc = (LibVlcDynamic)MediaPlayerEnd.VideoPlayer; libVlc.AudioTrackNumber = AudioTrackNumber; } }
private void VideoEndLoaded(object sender, EventArgs e) { MediaPlayerEnd.Pause(); GotoSubtitlePosition(MediaPlayerEnd); if (AudioTrackNumber >= 0 && MediaPlayerEnd.VideoPlayer is LibVlcDynamic) { var libVlc = (LibVlcDynamic)MediaPlayerEnd.VideoPlayer; libVlc.AudioTrackNumber = AudioTrackNumber; } else if (AudioTrackNumber >= 0 && MediaPlayerEnd.VideoPlayer is LibMpvDynamic) { var libMpv = (LibMpvDynamic)MediaPlayerEnd.VideoPlayer; libMpv.AudioTrackNumber = AudioTrackNumber; } }
private void VisualSync_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.Cancel; } else if (e.KeyData == UiUtil.HelpKeys) { UiUtil.ShowHelp("#visual_sync"); } else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.O) { ButtonOpenMovieClick(null, null); } else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.F) { if (_isStartSceneActive) { ButtonFindTextStartClick(null, null); } else { ButtonFindTextEndClick(null, null); } } else if (MediaPlayerStart != null && MediaPlayerEnd != null) { if (e.Modifiers == Keys.Control && e.KeyCode == Keys.S) { if (_isStartSceneActive) { _startStopPosition = -1; if (!MediaPlayerStart.IsPaused) { MediaPlayerStart.Pause(); } } else { _endStopPosition = -1; if (!MediaPlayerEnd.IsPaused) { MediaPlayerEnd.Pause(); } } } else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.P) { if (_isStartSceneActive) { _startStopPosition = -1; MediaPlayerStart.TogglePlayPause(); } else { _endStopPosition = -1; MediaPlayerStart.TogglePlayPause(); } } else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Left) { if (_isStartSceneActive) { GoBackSeconds(0.5, MediaPlayerStart); } else { GoBackSeconds(0.5, MediaPlayerEnd); } e.SuppressKeyPress = true; } else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right) { if (_isStartSceneActive) { GoBackSeconds(-0.5, MediaPlayerStart); } else { GoBackSeconds(-0.5, MediaPlayerEnd); } e.SuppressKeyPress = true; } else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Left) { if (_isStartSceneActive) { GoBackSeconds(0.1, MediaPlayerStart); } else { GoBackSeconds(0.1, MediaPlayerEnd); } e.SuppressKeyPress = true; } else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Right) { if (_isStartSceneActive) { GoBackSeconds(-0.1, MediaPlayerStart); } else { GoBackSeconds(-0.1, MediaPlayerEnd); } e.SuppressKeyPress = true; } else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Right) { if (_isStartSceneActive) { GoBackSeconds(1.0, MediaPlayerStart); } else { GoBackSeconds(1.0, MediaPlayerEnd); } e.SuppressKeyPress = true; } else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Left) { if (_isStartSceneActive) { GoBackSeconds(-1.0, MediaPlayerStart); } else { GoBackSeconds(-1.0, MediaPlayerEnd); } e.SuppressKeyPress = true; } else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) { if (_isStartSceneActive) { MediaPlayerStart.TogglePlayPause(); } else { MediaPlayerEnd.TogglePlayPause(); } e.SuppressKeyPress = true; } } }
private void VideoEndEnded(object sender, EventArgs e) { MediaPlayerEnd.Pause(); }