Add shortcuts to play with 1.5 and 2.0 speed

This commit is contained in:
OmrSi 2022-08-16 18:34:33 +03:00
parent bd0091b05d
commit a23cc80f1d
9 changed files with 71 additions and 5 deletions

View File

@ -2459,6 +2459,8 @@ can edit in same subtitle file (collaboration)</Information>
<WaveformGoToNextChapter>Go to next chapter</WaveformGoToNextChapter>
<WaveformSelectNextSubtitle>Select next subtitle (from video position, keep video pos)</WaveformSelectNextSubtitle>
<TogglePlayPause>Toggle play/pause</TogglePlayPause>
<Play150Speed>Play video with 1.5x speed</Play150Speed>
<Play200Speed>Play video with 2.0x speed</Play200Speed>
<Pause>Pause</Pause>
<Fullscreen>Fullscreen</Fullscreen>
<PlayRateSlower>Play rate slower</PlayRateSlower>

View File

@ -2255,6 +2255,8 @@ $HorzAlign = Center
public string MainVideoPlayFromJustBefore { get; set; }
public string MainVideoPlayFromBeginning { get; set; }
public string MainVideoPlayPauseToggle { get; set; }
public string MainVideoPlay150Speed { get; set; }
public string MainVideoPlay200Speed { get; set; }
public string MainVideoShowHideVideo { get; set; }
public string MainVideoShowWaveform { get; set; }
public string MainVideoFoucsSetVideoPosition { get; set; }
@ -8238,6 +8240,18 @@ $HorzAlign = Center
shortcuts.MainVideoPlayPauseToggle = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainVideoPlay150Speed");
if (subNode != null)
{
shortcuts.MainVideoPlay150Speed = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainVideoPlay200Speed");
if (subNode != null)
{
shortcuts.MainVideoPlay200Speed = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainVideoShowHideVideo");
if (subNode != null)
{
@ -10665,6 +10679,8 @@ $HorzAlign = Center
textWriter.WriteElementString("MainVideoPlayFromJustBefore", shortcuts.MainVideoPlayFromJustBefore);
textWriter.WriteElementString("MainVideoPlayFromBeginning", shortcuts.MainVideoPlayFromBeginning);
textWriter.WriteElementString("MainVideoPlayPauseToggle", shortcuts.MainVideoPlayPauseToggle);
textWriter.WriteElementString("MainVideoPlay150Speed", shortcuts.MainVideoPlay150Speed);
textWriter.WriteElementString("MainVideoPlay200Speed", shortcuts.MainVideoPlay200Speed);
textWriter.WriteElementString("MainVideoShowHideVideo", shortcuts.MainVideoShowHideVideo);
textWriter.WriteElementString("MainVideoShowWaveform", shortcuts.MainVideoShowWaveform);
textWriter.WriteElementString("MainVideoFoucsSetVideoPosition", shortcuts.MainVideoFoucsSetVideoPosition);

View File

@ -85,6 +85,7 @@ namespace Nikse.SubtitleEdit.Controls
private bool _isMuted;
private double? _muteOldVolume;
public bool PlayedWithCustomeSpeed;
private readonly System.ComponentModel.ComponentResourceManager _resources;
public int ControlsHeight = 47;
private const int OriginalSubtitlesHeight = 57;
@ -1759,6 +1760,11 @@ namespace Nikse.SubtitleEdit.Controls
_pictureBoxPlay.Visible = true;
_pictureBoxPlay.BringToFront();
RefreshProgressBar();
if (PlayedWithCustomeSpeed)
{
VideoPlayer.PlayRate = 1.0;
}
}
}

View File

@ -16739,6 +16739,22 @@ namespace Nikse.SubtitleEdit.Forms
System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(1), () => mediaPlayer.TogglePlayPause());
}
}
else if (e.KeyData == _shortcuts.VideoPlay150Speed)
{
if (mediaPlayer.VideoPlayer != null)
{
SetPlayRateAndPlay(150);
e.SuppressKeyPress = true;
}
}
else if (e.KeyData == _shortcuts.VideoPlay200Speed)
{
if (mediaPlayer.VideoPlayer != null)
{
SetPlayRateAndPlay(200);
e.SuppressKeyPress = true;
}
}
else if (e.KeyData == _shortcuts.VideoPause)
{
if (mediaPlayer.VideoPlayer != null)
@ -24434,7 +24450,7 @@ namespace Nikse.SubtitleEdit.Forms
var backColor = UiUtil.BackColor;
for (int i = 30; i <= 300; i += 10)
{
toolStripSplitButtonPlayRate.DropDownItems.Add(new ToolStripMenuItem(i + "%", null, SetPlayRate) { Checked = i == 100, BackColor = backColor, ForeColor = foreColor });
toolStripSplitButtonPlayRate.DropDownItems.Add(new ToolStripMenuItem(i + "%", null, SetPlayRate, i.ToString()) { Checked = i == 100, BackColor = backColor, ForeColor = foreColor });
}
}
@ -24446,12 +24462,18 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void SetPlayRateAndPlay(int playRate)
{
SetPlayRate(toolStripSplitButtonPlayRate.DropDownItems[playRate.ToString()], null, false, true);
mediaPlayer.Play();
}
private void SetPlayRate(object sender, EventArgs e)
{
SetPlayRate(sender, e, false);
}
private void SetPlayRate(object sender, EventArgs e, bool skipStatusMessage)
private void SetPlayRate(object sender, EventArgs e, bool skipStatusMessage, bool playedWithCustomeSpeed = false)
{
if (!(sender is ToolStripMenuItem playRateDropDownItem) || mediaPlayer == null || mediaPlayer.VideoPlayer == null)
{
@ -24463,19 +24485,23 @@ namespace Nikse.SubtitleEdit.Forms
item.Checked = false;
}
playRateDropDownItem.Checked = true;
var percentText = playRateDropDownItem.Text.TrimEnd('%');
var factor = double.Parse(percentText) / 100.0;
if (!skipStatusMessage)
{
ShowStatus(string.Format(_language.SetPlayRateX, percentText));
}
var factor = double.Parse(percentText) / 100.0;
toolStripSplitButtonPlayRate.Image = Math.Abs(factor - 1) < 0.01 ? imageListPlayRate.Images[0] : imageListPlayRate.Images[1];
if (!playedWithCustomeSpeed)
{
playRateDropDownItem.Checked = true;
toolStripSplitButtonPlayRate.Image = Math.Abs(factor - 1) < 0.01 ? imageListPlayRate.Images[0] : imageListPlayRate.Images[1];
}
try
{
mediaPlayer.VideoPlayer.PlayRate = factor;
mediaPlayer.PlayedWithCustomeSpeed = playedWithCustomeSpeed;
}
catch
{

View File

@ -1340,6 +1340,8 @@ namespace Nikse.SubtitleEdit.Forms.Options
AddNode(videoNode, LanguageSettings.Current.Main.Menu.Video.OpenVideo, nameof(Configuration.Settings.Shortcuts.MainVideoOpen), true);
AddNode(videoNode, LanguageSettings.Current.Main.Menu.Video.CloseVideo, nameof(Configuration.Settings.Shortcuts.MainVideoClose), true);
AddNode(videoNode, language.TogglePlayPause, nameof(Configuration.Settings.Shortcuts.MainVideoPlayPauseToggle));
AddNode(videoNode, language.Play150Speed, nameof(Configuration.Settings.Shortcuts.MainVideoPlay150Speed));
AddNode(videoNode, language.Play200Speed, nameof(Configuration.Settings.Shortcuts.MainVideoPlay200Speed));
AddNode(videoNode, language.Pause, nameof(Configuration.Settings.Shortcuts.MainVideoPause));
AddNode(videoNode, LanguageSettings.Current.Main.VideoControls.Stop, nameof(Configuration.Settings.Shortcuts.MainVideoStop));
AddNode(videoNode, LanguageSettings.Current.Main.VideoControls.PlayFromJustBeforeText, nameof(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore));

View File

@ -2788,6 +2788,8 @@ can edit in same subtitle file (collaboration)",
PlaySelectedLines = "Play selected lines",
Pause = "Pause",
TogglePlayPause = "Toggle play/pause",
Play150Speed = "Play video with 1.5x speed",
Play200Speed = "Play video with 2.0x speed",
Fullscreen = "Fullscreen",
PlayRateSlower = "Play rate slower",
PlayRateFaster = "Play rate faster",

View File

@ -6742,6 +6742,12 @@ namespace Nikse.SubtitleEdit.Logic
case "Settings/TogglePlayPause":
language.Settings.TogglePlayPause = reader.Value;
break;
case "Settings/Play150Speed":
language.Settings.Play150Speed = reader.Value;
break;
case "Settings/Play200Speed":
language.Settings.Play200Speed = reader.Value;
break;
case "Settings/Pause":
language.Settings.Pause = reader.Value;
break;

View File

@ -2641,6 +2641,8 @@
public string WaveformGoToNextChapter { get; set; }
public string WaveformSelectNextSubtitle { get; set; }
public string TogglePlayPause { get; set; }
public string Play150Speed { get; set; }
public string Play200Speed { get; set; }
public string Pause { get; set; }
public string Fullscreen { get; set; }
public string PlayRateSlower { get; set; }

View File

@ -39,6 +39,8 @@ namespace Nikse.SubtitleEdit.Logic
public Keys VideoPause { get; set; }
public Keys VideoStop { get; set; }
public Keys VideoPlayPauseToggle { get; set; }
public Keys VideoPlay150Speed { get; set; }
public Keys VideoPlay200Speed { get; set; }
public Keys MainVideoPlayFromJustBefore { get; set; }
public Keys MainVideoPlayFromBeginning { get; set; }
public Keys Video1FrameLeft { get; set; }
@ -270,6 +272,8 @@ namespace Nikse.SubtitleEdit.Logic
MainVideoFocusSetVideoPosition = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoFoucsSetVideoPosition);
ToggleVideoDockUndock = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls);
VideoPlayPauseToggle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlayPauseToggle);
VideoPlay150Speed = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlay150Speed);
VideoPlay200Speed = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlay200Speed);
Video1FrameLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideo1FrameLeft);
Video1FrameRight = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideo1FrameRight);
Video1FrameLeftWithPlay = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideo1FrameLeftWithPlay);