mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Merge pull request #1216 from jdpurcell/playselection
Play audio selection fix/enhancement
This commit is contained in:
commit
6c095e8d3f
@ -1688,7 +1688,8 @@ can edit in same subtitle file (collaboration)</Information>
|
|||||||
<WaveformSeekSilenceForward>Seek silence forward</WaveformSeekSilenceForward>
|
<WaveformSeekSilenceForward>Seek silence forward</WaveformSeekSilenceForward>
|
||||||
<WaveformSeekSilenceBack>Seek silence back</WaveformSeekSilenceBack>
|
<WaveformSeekSilenceBack>Seek silence back</WaveformSeekSilenceBack>
|
||||||
<WaveformAddTextHere>Add text here (for new selection)</WaveformAddTextHere>
|
<WaveformAddTextHere>Add text here (for new selection)</WaveformAddTextHere>
|
||||||
<WaveformPlayNewSelection>Play new selection</WaveformPlayNewSelection>
|
<WaveformPlayNewSelection>Play selection</WaveformPlayNewSelection>
|
||||||
|
<WaveformPlayNewSelectionEnd>Play end of selection</WaveformPlayNewSelectionEnd>
|
||||||
<WaveformPlayFirstSelectedSubtitle>Play first selected subtitle</WaveformPlayFirstSelectedSubtitle>
|
<WaveformPlayFirstSelectedSubtitle>Play first selected subtitle</WaveformPlayFirstSelectedSubtitle>
|
||||||
<WaveformFocusListView>Focus list view</WaveformFocusListView>
|
<WaveformFocusListView>Focus list view</WaveformFocusListView>
|
||||||
<GoBack1Frame>One frame back</GoBack1Frame>
|
<GoBack1Frame>One frame back</GoBack1Frame>
|
||||||
|
@ -1965,7 +1965,8 @@ can edit in same subtitle file (collaboration)",
|
|||||||
WaveformSeekSilenceForward = "Seek silence forward",
|
WaveformSeekSilenceForward = "Seek silence forward",
|
||||||
WaveformSeekSilenceBack = "Seek silence back",
|
WaveformSeekSilenceBack = "Seek silence back",
|
||||||
WaveformAddTextHere = "Add text here (for new selection)",
|
WaveformAddTextHere = "Add text here (for new selection)",
|
||||||
WaveformPlayNewSelection = "Play new selection",
|
WaveformPlayNewSelection = "Play selection",
|
||||||
|
WaveformPlayNewSelectionEnd = "Play end of selection",
|
||||||
WaveformPlayFirstSelectedSubtitle = "Play first selected subtitle",
|
WaveformPlayFirstSelectedSubtitle = "Play first selected subtitle",
|
||||||
WaveformFocusListView = "Focus list view",
|
WaveformFocusListView = "Focus list view",
|
||||||
GoBack1Frame = "One frame back",
|
GoBack1Frame = "One frame back",
|
||||||
|
@ -4522,6 +4522,9 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
case "Settings/WaveformPlayNewSelection":
|
case "Settings/WaveformPlayNewSelection":
|
||||||
language.Settings.WaveformPlayNewSelection = reader.Value;
|
language.Settings.WaveformPlayNewSelection = reader.Value;
|
||||||
break;
|
break;
|
||||||
|
case "Settings/WaveformPlayNewSelectionEnd":
|
||||||
|
language.Settings.WaveformPlayNewSelectionEnd = reader.Value;
|
||||||
|
break;
|
||||||
case "Settings/WaveformPlayFirstSelectedSubtitle":
|
case "Settings/WaveformPlayFirstSelectedSubtitle":
|
||||||
language.Settings.WaveformPlayFirstSelectedSubtitle = reader.Value;
|
language.Settings.WaveformPlayFirstSelectedSubtitle = reader.Value;
|
||||||
break;
|
break;
|
||||||
|
@ -1848,6 +1848,7 @@
|
|||||||
public string WaveformSeekSilenceBack { get; set; }
|
public string WaveformSeekSilenceBack { get; set; }
|
||||||
public string WaveformAddTextHere { get; set; }
|
public string WaveformAddTextHere { get; set; }
|
||||||
public string WaveformPlayNewSelection { get; set; }
|
public string WaveformPlayNewSelection { get; set; }
|
||||||
|
public string WaveformPlayNewSelectionEnd { get; set; }
|
||||||
public string WaveformPlayFirstSelectedSubtitle { get; set; }
|
public string WaveformPlayFirstSelectedSubtitle { get; set; }
|
||||||
public string WaveformFocusListView { get; set; }
|
public string WaveformFocusListView { get; set; }
|
||||||
public string GoBack1Frame { get; set; }
|
public string GoBack1Frame { get; set; }
|
||||||
|
@ -872,6 +872,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
public string WaveformZoomIn { get; set; }
|
public string WaveformZoomIn { get; set; }
|
||||||
public string WaveformZoomOut { get; set; }
|
public string WaveformZoomOut { get; set; }
|
||||||
public string WaveformPlaySelection { get; set; }
|
public string WaveformPlaySelection { get; set; }
|
||||||
|
public string WaveformPlaySelectionEnd { get; set; }
|
||||||
public string WaveformSearchSilenceForward { get; set; }
|
public string WaveformSearchSilenceForward { get; set; }
|
||||||
public string WaveformSearchSilenceBack { get; set; }
|
public string WaveformSearchSilenceBack { get; set; }
|
||||||
public string WaveformAddTextHere { get; set; }
|
public string WaveformAddTextHere { get; set; }
|
||||||
@ -975,6 +976,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
WaveformVerticalZoom = "Shift+Add";
|
WaveformVerticalZoom = "Shift+Add";
|
||||||
WaveformVerticalZoomOut = "Shift+Subtract";
|
WaveformVerticalZoomOut = "Shift+Subtract";
|
||||||
WaveformPlaySelection = string.Empty;
|
WaveformPlaySelection = string.Empty;
|
||||||
|
WaveformPlaySelectionEnd = string.Empty;
|
||||||
GeneralPlayFirstSelected = string.Empty;
|
GeneralPlayFirstSelected = string.Empty;
|
||||||
WaveformSearchSilenceForward = string.Empty;
|
WaveformSearchSilenceForward = string.Empty;
|
||||||
WaveformSearchSilenceBack = string.Empty;
|
WaveformSearchSilenceBack = string.Empty;
|
||||||
@ -2545,6 +2547,9 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
subNode = node.SelectSingleNode("WaveformPlaySelection");
|
subNode = node.SelectSingleNode("WaveformPlaySelection");
|
||||||
if (subNode != null)
|
if (subNode != null)
|
||||||
settings.Shortcuts.WaveformPlaySelection = subNode.InnerText;
|
settings.Shortcuts.WaveformPlaySelection = subNode.InnerText;
|
||||||
|
subNode = node.SelectSingleNode("WaveformPlaySelectionEnd");
|
||||||
|
if (subNode != null)
|
||||||
|
settings.Shortcuts.WaveformPlaySelectionEnd = subNode.InnerText;
|
||||||
subNode = node.SelectSingleNode("WaveformSearchSilenceForward");
|
subNode = node.SelectSingleNode("WaveformSearchSilenceForward");
|
||||||
if (subNode != null)
|
if (subNode != null)
|
||||||
settings.Shortcuts.WaveformSearchSilenceForward = subNode.InnerText;
|
settings.Shortcuts.WaveformSearchSilenceForward = subNode.InnerText;
|
||||||
@ -3159,6 +3164,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
textWriter.WriteElementString("WaveformZoomIn", settings.Shortcuts.WaveformZoomIn);
|
textWriter.WriteElementString("WaveformZoomIn", settings.Shortcuts.WaveformZoomIn);
|
||||||
textWriter.WriteElementString("WaveformZoomOut", settings.Shortcuts.WaveformZoomOut);
|
textWriter.WriteElementString("WaveformZoomOut", settings.Shortcuts.WaveformZoomOut);
|
||||||
textWriter.WriteElementString("WaveformPlaySelection", settings.Shortcuts.WaveformPlaySelection);
|
textWriter.WriteElementString("WaveformPlaySelection", settings.Shortcuts.WaveformPlaySelection);
|
||||||
|
textWriter.WriteElementString("WaveformPlaySelectionEnd", settings.Shortcuts.WaveformPlaySelectionEnd);
|
||||||
textWriter.WriteElementString("WaveformSearchSilenceForward", settings.Shortcuts.WaveformSearchSilenceForward);
|
textWriter.WriteElementString("WaveformSearchSilenceForward", settings.Shortcuts.WaveformSearchSilenceForward);
|
||||||
textWriter.WriteElementString("WaveformSearchSilenceBack", settings.Shortcuts.WaveformSearchSilenceBack);
|
textWriter.WriteElementString("WaveformSearchSilenceBack", settings.Shortcuts.WaveformSearchSilenceBack);
|
||||||
textWriter.WriteElementString("WaveformAddTextHere", settings.Shortcuts.WaveformAddTextHere);
|
textWriter.WriteElementString("WaveformAddTextHere", settings.Shortcuts.WaveformAddTextHere);
|
||||||
|
@ -184,6 +184,7 @@ namespace Nikse.SubtitleEdit.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Paragraph NewSelectionParagraph { get; set; }
|
public Paragraph NewSelectionParagraph { get; set; }
|
||||||
|
public Paragraph SelectedParagraph { get { return _selectedParagraph; } }
|
||||||
public Paragraph RightClickedParagraph { get; private set; }
|
public Paragraph RightClickedParagraph { get; private set; }
|
||||||
public double RightClickedSeconds { get; private set; }
|
public double RightClickedSeconds { get; private set; }
|
||||||
|
|
||||||
|
@ -187,6 +187,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
private Keys _waveformZoomIn = Keys.None;
|
private Keys _waveformZoomIn = Keys.None;
|
||||||
private Keys _waveformZoomOut = Keys.None;
|
private Keys _waveformZoomOut = Keys.None;
|
||||||
private Keys _waveformPlaySelection = Keys.None;
|
private Keys _waveformPlaySelection = Keys.None;
|
||||||
|
private Keys _waveformPlaySelectionEnd = Keys.None;
|
||||||
private Keys _waveformSearchSilenceForward = Keys.None;
|
private Keys _waveformSearchSilenceForward = Keys.None;
|
||||||
private Keys _waveformSearchSilenceBack = Keys.None;
|
private Keys _waveformSearchSilenceBack = Keys.None;
|
||||||
private Keys _waveformAddTextAtHere = Keys.None;
|
private Keys _waveformAddTextAtHere = Keys.None;
|
||||||
@ -10224,9 +10225,9 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
PlayFirstSelectedSubtitle();
|
PlayFirstSelectedSubtitle();
|
||||||
}
|
}
|
||||||
else if (audioVisualizer != null && audioVisualizer.Visible && e.KeyData == _waveformPlaySelection)
|
else if (audioVisualizer != null && audioVisualizer.Visible && (e.KeyData == _waveformPlaySelection || e.KeyData == _waveformPlaySelectionEnd))
|
||||||
{
|
{
|
||||||
toolStripMenuItemWaveformPlaySelection_Click(null, null);
|
WaveformPlaySelection(nearEnd: e.KeyData == _waveformPlaySelectionEnd);
|
||||||
e.SuppressKeyPress = true;
|
e.SuppressKeyPress = true;
|
||||||
}
|
}
|
||||||
else if (audioVisualizer != null && audioVisualizer.Visible && e.KeyData == _waveformSearchSilenceForward)
|
else if (audioVisualizer != null && audioVisualizer.Visible && e.KeyData == _waveformSearchSilenceForward)
|
||||||
@ -14354,6 +14355,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
_waveformZoomIn = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformZoomIn);
|
_waveformZoomIn = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformZoomIn);
|
||||||
_waveformZoomOut = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformZoomOut);
|
_waveformZoomOut = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformZoomOut);
|
||||||
_waveformPlaySelection = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformPlaySelection);
|
_waveformPlaySelection = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformPlaySelection);
|
||||||
|
_waveformPlaySelectionEnd = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformPlaySelectionEnd);
|
||||||
_waveformSearchSilenceForward = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformSearchSilenceForward);
|
_waveformSearchSilenceForward = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformSearchSilenceForward);
|
||||||
_waveformSearchSilenceBack = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack);
|
_waveformSearchSilenceBack = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack);
|
||||||
_waveformAddTextAtHere = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformAddTextHere);
|
_waveformAddTextAtHere = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformAddTextHere);
|
||||||
@ -15052,19 +15054,29 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemWaveformPlaySelection_Click(object sender, EventArgs e)
|
private void toolStripMenuItemWaveformPlaySelection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
WaveformPlaySelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WaveformPlaySelection(bool nearEnd = false)
|
||||||
{
|
{
|
||||||
if (mediaPlayer.VideoPlayer != null)
|
if (mediaPlayer.VideoPlayer != null)
|
||||||
{
|
{
|
||||||
var p = audioVisualizer.NewSelectionParagraph;
|
var p =
|
||||||
if (p == null)
|
audioVisualizer.NewSelectionParagraph ??
|
||||||
p = audioVisualizer.RightClickedParagraph;
|
audioVisualizer.SelectedParagraph;
|
||||||
|
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds;
|
double startSeconds = p.StartTime.TotalSeconds;
|
||||||
|
_endSeconds = p.EndTime.TotalSeconds;
|
||||||
|
if (nearEnd)
|
||||||
|
{
|
||||||
|
startSeconds = Math.Max(startSeconds, _endSeconds - 1.0);
|
||||||
|
}
|
||||||
|
mediaPlayer.CurrentPosition = startSeconds;
|
||||||
UiUtil.ShowSubtitle(_subtitle.Paragraphs, mediaPlayer);
|
UiUtil.ShowSubtitle(_subtitle.Paragraphs, mediaPlayer);
|
||||||
mediaPlayer.Play();
|
mediaPlayer.Play();
|
||||||
_endSeconds = p.EndTime.TotalSeconds;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,6 +757,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
audioVisualizerNode.Nodes.Add(language.WaveformSeekSilenceBack + GetShortcutText(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack));
|
audioVisualizerNode.Nodes.Add(language.WaveformSeekSilenceBack + GetShortcutText(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack));
|
||||||
audioVisualizerNode.Nodes.Add(language.WaveformAddTextHere + GetShortcutText(Configuration.Settings.Shortcuts.WaveformAddTextHere));
|
audioVisualizerNode.Nodes.Add(language.WaveformAddTextHere + GetShortcutText(Configuration.Settings.Shortcuts.WaveformAddTextHere));
|
||||||
audioVisualizerNode.Nodes.Add(language.WaveformPlayNewSelection + GetShortcutText(Configuration.Settings.Shortcuts.WaveformPlaySelection));
|
audioVisualizerNode.Nodes.Add(language.WaveformPlayNewSelection + GetShortcutText(Configuration.Settings.Shortcuts.WaveformPlaySelection));
|
||||||
|
audioVisualizerNode.Nodes.Add(language.WaveformPlayNewSelectionEnd + GetShortcutText(Configuration.Settings.Shortcuts.WaveformPlaySelectionEnd));
|
||||||
audioVisualizerNode.Nodes.Add(Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPosition + GetShortcutText(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition));
|
audioVisualizerNode.Nodes.Add(Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPosition + GetShortcutText(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition));
|
||||||
audioVisualizerNode.Nodes.Add(language.WaveformFocusListView + GetShortcutText(Configuration.Settings.Shortcuts.WaveformFocusListView));
|
audioVisualizerNode.Nodes.Add(language.WaveformFocusListView + GetShortcutText(Configuration.Settings.Shortcuts.WaveformFocusListView));
|
||||||
treeViewShortcuts.Nodes.Add(audioVisualizerNode);
|
treeViewShortcuts.Nodes.Add(audioVisualizerNode);
|
||||||
@ -1535,6 +1536,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
Configuration.Settings.Shortcuts.WaveformZoomOut = GetShortcut(node.Text);
|
Configuration.Settings.Shortcuts.WaveformZoomOut = GetShortcut(node.Text);
|
||||||
else if (text == (Configuration.Settings.Language.Settings.WaveformPlayNewSelection).Replace("&", string.Empty))
|
else if (text == (Configuration.Settings.Language.Settings.WaveformPlayNewSelection).Replace("&", string.Empty))
|
||||||
Configuration.Settings.Shortcuts.WaveformPlaySelection = GetShortcut(node.Text);
|
Configuration.Settings.Shortcuts.WaveformPlaySelection = GetShortcut(node.Text);
|
||||||
|
else if (text == (Configuration.Settings.Language.Settings.WaveformPlayNewSelectionEnd).Replace("&", string.Empty))
|
||||||
|
Configuration.Settings.Shortcuts.WaveformPlaySelectionEnd = GetShortcut(node.Text);
|
||||||
else if (text == (Configuration.Settings.Language.Settings.VerticalZoom).Replace("&", string.Empty))
|
else if (text == (Configuration.Settings.Language.Settings.VerticalZoom).Replace("&", string.Empty))
|
||||||
Configuration.Settings.Shortcuts.WaveformVerticalZoom = GetShortcut(node.Text);
|
Configuration.Settings.Shortcuts.WaveformVerticalZoom = GetShortcut(node.Text);
|
||||||
else if (text == (Configuration.Settings.Language.Settings.VerticalZoomOut).Replace("&", string.Empty))
|
else if (text == (Configuration.Settings.Language.Settings.VerticalZoomOut).Replace("&", string.Empty))
|
||||||
|
@ -4529,6 +4529,9 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
case "Settings/WaveformPlayNewSelection":
|
case "Settings/WaveformPlayNewSelection":
|
||||||
language.Settings.WaveformPlayNewSelection = reader.Value;
|
language.Settings.WaveformPlayNewSelection = reader.Value;
|
||||||
break;
|
break;
|
||||||
|
case "Settings/WaveformPlayNewSelectionEnd":
|
||||||
|
language.Settings.WaveformPlayNewSelectionEnd = reader.Value;
|
||||||
|
break;
|
||||||
case "Settings/WaveformPlayFirstSelectedSubtitle":
|
case "Settings/WaveformPlayFirstSelectedSubtitle":
|
||||||
language.Settings.WaveformPlayFirstSelectedSubtitle = reader.Value;
|
language.Settings.WaveformPlayFirstSelectedSubtitle = reader.Value;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user