Merge pull request #1216 from jdpurcell/playselection

Play audio selection fix/enhancement
This commit is contained in:
Nikolaj Olsson 2015-09-06 18:30:04 +02:00
commit 6c095e8d3f
9 changed files with 40 additions and 9 deletions

View File

@ -1688,7 +1688,8 @@ can edit in same subtitle file (collaboration)</Information>
<WaveformSeekSilenceForward>Seek silence forward</WaveformSeekSilenceForward>
<WaveformSeekSilenceBack>Seek silence back</WaveformSeekSilenceBack>
<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>
<WaveformFocusListView>Focus list view</WaveformFocusListView>
<GoBack1Frame>One frame back</GoBack1Frame>

View File

@ -1965,7 +1965,8 @@ can edit in same subtitle file (collaboration)",
WaveformSeekSilenceForward = "Seek silence forward",
WaveformSeekSilenceBack = "Seek silence back",
WaveformAddTextHere = "Add text here (for new selection)",
WaveformPlayNewSelection = "Play new selection",
WaveformPlayNewSelection = "Play selection",
WaveformPlayNewSelectionEnd = "Play end of selection",
WaveformPlayFirstSelectedSubtitle = "Play first selected subtitle",
WaveformFocusListView = "Focus list view",
GoBack1Frame = "One frame back",

View File

@ -4522,6 +4522,9 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/WaveformPlayNewSelection":
language.Settings.WaveformPlayNewSelection = reader.Value;
break;
case "Settings/WaveformPlayNewSelectionEnd":
language.Settings.WaveformPlayNewSelectionEnd = reader.Value;
break;
case "Settings/WaveformPlayFirstSelectedSubtitle":
language.Settings.WaveformPlayFirstSelectedSubtitle = reader.Value;
break;

View File

@ -1848,6 +1848,7 @@
public string WaveformSeekSilenceBack { get; set; }
public string WaveformAddTextHere { get; set; }
public string WaveformPlayNewSelection { get; set; }
public string WaveformPlayNewSelectionEnd { get; set; }
public string WaveformPlayFirstSelectedSubtitle { get; set; }
public string WaveformFocusListView { get; set; }
public string GoBack1Frame { get; set; }

View File

@ -872,6 +872,7 @@ namespace Nikse.SubtitleEdit.Core
public string WaveformZoomIn { get; set; }
public string WaveformZoomOut { get; set; }
public string WaveformPlaySelection { get; set; }
public string WaveformPlaySelectionEnd { get; set; }
public string WaveformSearchSilenceForward { get; set; }
public string WaveformSearchSilenceBack { get; set; }
public string WaveformAddTextHere { get; set; }
@ -975,6 +976,7 @@ namespace Nikse.SubtitleEdit.Core
WaveformVerticalZoom = "Shift+Add";
WaveformVerticalZoomOut = "Shift+Subtract";
WaveformPlaySelection = string.Empty;
WaveformPlaySelectionEnd = string.Empty;
GeneralPlayFirstSelected = string.Empty;
WaveformSearchSilenceForward = string.Empty;
WaveformSearchSilenceBack = string.Empty;
@ -2545,6 +2547,9 @@ namespace Nikse.SubtitleEdit.Core
subNode = node.SelectSingleNode("WaveformPlaySelection");
if (subNode != null)
settings.Shortcuts.WaveformPlaySelection = subNode.InnerText;
subNode = node.SelectSingleNode("WaveformPlaySelectionEnd");
if (subNode != null)
settings.Shortcuts.WaveformPlaySelectionEnd = subNode.InnerText;
subNode = node.SelectSingleNode("WaveformSearchSilenceForward");
if (subNode != null)
settings.Shortcuts.WaveformSearchSilenceForward = subNode.InnerText;
@ -3159,6 +3164,7 @@ namespace Nikse.SubtitleEdit.Core
textWriter.WriteElementString("WaveformZoomIn", settings.Shortcuts.WaveformZoomIn);
textWriter.WriteElementString("WaveformZoomOut", settings.Shortcuts.WaveformZoomOut);
textWriter.WriteElementString("WaveformPlaySelection", settings.Shortcuts.WaveformPlaySelection);
textWriter.WriteElementString("WaveformPlaySelectionEnd", settings.Shortcuts.WaveformPlaySelectionEnd);
textWriter.WriteElementString("WaveformSearchSilenceForward", settings.Shortcuts.WaveformSearchSilenceForward);
textWriter.WriteElementString("WaveformSearchSilenceBack", settings.Shortcuts.WaveformSearchSilenceBack);
textWriter.WriteElementString("WaveformAddTextHere", settings.Shortcuts.WaveformAddTextHere);

View File

@ -184,6 +184,7 @@ namespace Nikse.SubtitleEdit.Controls
}
public Paragraph NewSelectionParagraph { get; set; }
public Paragraph SelectedParagraph { get { return _selectedParagraph; } }
public Paragraph RightClickedParagraph { get; private set; }
public double RightClickedSeconds { get; private set; }

View File

@ -187,6 +187,7 @@ namespace Nikse.SubtitleEdit.Forms
private Keys _waveformZoomIn = Keys.None;
private Keys _waveformZoomOut = Keys.None;
private Keys _waveformPlaySelection = Keys.None;
private Keys _waveformPlaySelectionEnd = Keys.None;
private Keys _waveformSearchSilenceForward = Keys.None;
private Keys _waveformSearchSilenceBack = Keys.None;
private Keys _waveformAddTextAtHere = Keys.None;
@ -10224,9 +10225,9 @@ namespace Nikse.SubtitleEdit.Forms
{
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;
}
else if (audioVisualizer != null && audioVisualizer.Visible && e.KeyData == _waveformSearchSilenceForward)
@ -14354,6 +14355,7 @@ namespace Nikse.SubtitleEdit.Forms
_waveformZoomIn = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformZoomIn);
_waveformZoomOut = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformZoomOut);
_waveformPlaySelection = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformPlaySelection);
_waveformPlaySelectionEnd = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformPlaySelectionEnd);
_waveformSearchSilenceForward = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformSearchSilenceForward);
_waveformSearchSilenceBack = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack);
_waveformAddTextAtHere = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformAddTextHere);
@ -15052,19 +15054,29 @@ namespace Nikse.SubtitleEdit.Forms
}
private void toolStripMenuItemWaveformPlaySelection_Click(object sender, EventArgs e)
{
WaveformPlaySelection();
}
private void WaveformPlaySelection(bool nearEnd = false)
{
if (mediaPlayer.VideoPlayer != null)
{
var p = audioVisualizer.NewSelectionParagraph;
if (p == null)
p = audioVisualizer.RightClickedParagraph;
var p =
audioVisualizer.NewSelectionParagraph ??
audioVisualizer.SelectedParagraph;
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);
mediaPlayer.Play();
_endSeconds = p.EndTime.TotalSeconds;
}
}
}

View File

@ -757,6 +757,7 @@ namespace Nikse.SubtitleEdit.Forms
audioVisualizerNode.Nodes.Add(language.WaveformSeekSilenceBack + GetShortcutText(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack));
audioVisualizerNode.Nodes.Add(language.WaveformAddTextHere + GetShortcutText(Configuration.Settings.Shortcuts.WaveformAddTextHere));
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(language.WaveformFocusListView + GetShortcutText(Configuration.Settings.Shortcuts.WaveformFocusListView));
treeViewShortcuts.Nodes.Add(audioVisualizerNode);
@ -1535,6 +1536,8 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.Shortcuts.WaveformZoomOut = GetShortcut(node.Text);
else if (text == (Configuration.Settings.Language.Settings.WaveformPlayNewSelection).Replace("&", string.Empty))
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))
Configuration.Settings.Shortcuts.WaveformVerticalZoom = GetShortcut(node.Text);
else if (text == (Configuration.Settings.Language.Settings.VerticalZoomOut).Replace("&", string.Empty))

View File

@ -4529,6 +4529,9 @@ namespace Nikse.SubtitleEdit.Logic
case "Settings/WaveformPlayNewSelection":
language.Settings.WaveformPlayNewSelection = reader.Value;
break;
case "Settings/WaveformPlayNewSelectionEnd":
language.Settings.WaveformPlayNewSelectionEnd = reader.Value;
break;
case "Settings/WaveformPlayFirstSelectedSubtitle":
language.Settings.WaveformPlayFirstSelectedSubtitle = reader.Value;
break;