mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Allow for libmpv on video display of online subs - thx OmrSi :)
This commit is contained in:
parent
96f0487984
commit
1e19b347ec
@ -95,6 +95,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
public string VideoFileName { get; set; }
|
||||
public bool VideoFileNameIsUrl => VideoFileName != null &&
|
||||
(VideoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
|
||||
VideoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private DateTime _fileDateTime;
|
||||
private string _title;
|
||||
@ -4700,7 +4703,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(allText))
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName), String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
return DialogResult.Cancel;
|
||||
}
|
||||
|
||||
@ -5313,7 +5316,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (oldFavoriteFormats != Configuration.Settings.General.FavoriteSubtitleFormats)
|
||||
{
|
||||
UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, String.Empty);
|
||||
UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, string.Empty);
|
||||
}
|
||||
|
||||
SetLanguage(Configuration.Settings.General.Language);
|
||||
@ -20879,6 +20882,35 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ShowStatus(_language.Menu.Video.SmptTimeMode);
|
||||
}
|
||||
}
|
||||
|
||||
if (VideoFileNameIsUrl)
|
||||
{
|
||||
System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(2000), () => LoadVideoInfoAfterVideoFromUrlLoad());
|
||||
System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(5000), () => LoadVideoInfoAfterVideoFromUrlLoad());
|
||||
System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(10000), () => LoadVideoInfoAfterVideoFromUrlLoad());
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadVideoInfoAfterVideoFromUrlLoad()
|
||||
{
|
||||
if (VideoFileNameIsUrl && _videoInfo == null && mediaPlayer.VideoPlayer is LibMpvDynamic libMpv && libMpv.VideoWidth > 0)
|
||||
{
|
||||
_videoInfo = new VideoInfo()
|
||||
{
|
||||
Width = libMpv.VideoWidth,
|
||||
Height = libMpv.VideoHeight,
|
||||
TotalSeconds = libMpv.Duration,
|
||||
TotalMilliseconds = libMpv.Duration * 1000.0,
|
||||
FramesPerSecond = libMpv.VideoTotalFrames,
|
||||
TotalFrames = libMpv.VideoFps,
|
||||
Success = true,
|
||||
};
|
||||
mediaPlayer.VideoWidth = _videoInfo.Width;
|
||||
mediaPlayer.VideoHeight = _videoInfo.Height;
|
||||
mediaPlayer.SetSubtitleText(string.Empty, new Paragraph(), new Subtitle(), GetCurrentSubtitleFormat());
|
||||
UiUtil.ShowSubtitle(_subtitle, mediaPlayer, GetCurrentSubtitleFormat());
|
||||
AddEmptyWaveform();
|
||||
}
|
||||
}
|
||||
|
||||
private void VideoEnded(object sender, EventArgs e)
|
||||
@ -23221,6 +23253,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
//if (_videoInfo != null && mediaPlayer.VideoWidth == 0 && _videoInfo.Width > 0)
|
||||
//{
|
||||
// mediaPlayer.VideoWidth = _videoInfo.Width;
|
||||
// mediaPlayer.VideoHeight = _videoInfo.Height;
|
||||
//}
|
||||
|
||||
_timerSlow.Start();
|
||||
}
|
||||
|
||||
@ -24294,25 +24332,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (audioVisualizer.WavePeaks == null)
|
||||
{
|
||||
if (VideoFileName != null && (VideoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
|
||||
VideoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
|
||||
if (VideoFileNameIsUrl)
|
||||
{
|
||||
if (mediaPlayer.Duration > 0)
|
||||
{
|
||||
ShowStatus(LanguageSettings.Current.AddWaveform.GeneratingPeakFile);
|
||||
var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName);
|
||||
audioVisualizer.ZoomFactor = 1.0;
|
||||
audioVisualizer.VerticalZoomFactor = 1.0;
|
||||
SelectZoomTextInComboBox();
|
||||
audioVisualizer.WavePeaks = WavePeakGenerator.GenerateEmptyPeaks(peakWaveFileName, (int)mediaPlayer.Duration);
|
||||
if (smpteTimeModedropFrameToolStripMenuItem.Checked)
|
||||
{
|
||||
audioVisualizer.UseSmpteDropFrameTime();
|
||||
}
|
||||
|
||||
timerWaveform.Start();
|
||||
}
|
||||
|
||||
AddEmptyWaveform();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -24392,6 +24414,24 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void AddEmptyWaveform()
|
||||
{
|
||||
if (mediaPlayer.Duration > 0)
|
||||
{
|
||||
var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName);
|
||||
audioVisualizer.ZoomFactor = 1.0;
|
||||
audioVisualizer.VerticalZoomFactor = 1.0;
|
||||
SelectZoomTextInComboBox();
|
||||
audioVisualizer.WavePeaks = WavePeakGenerator.GenerateEmptyPeaks(peakWaveFileName, (int)mediaPlayer.Duration);
|
||||
if (smpteTimeModedropFrameToolStripMenuItem.Checked)
|
||||
{
|
||||
audioVisualizer.UseSmpteDropFrameTime();
|
||||
}
|
||||
|
||||
timerWaveform.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadWaveform(string fileName, int audioTrackNumber)
|
||||
{
|
||||
if (audioVisualizer.WavePeaks != null)
|
||||
@ -24407,8 +24447,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
audioTrackNumber -= 1;
|
||||
}
|
||||
|
||||
if (VideoFileName != null && (VideoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
|
||||
VideoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
|
||||
if (VideoFileNameIsUrl)
|
||||
{
|
||||
if (mediaPlayer.Duration > 0)
|
||||
{
|
||||
@ -28564,7 +28603,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (mediaPlayer != null && mediaPlayer.VideoPlayer is LibMpvDynamic libMpv)
|
||||
{
|
||||
// refresh mpv text
|
||||
mediaPlayer.SetSubtitleText("", new Paragraph(), new Subtitle(), GetCurrentSubtitleFormat());
|
||||
mediaPlayer.SetSubtitleText(string.Empty, new Paragraph(), new Subtitle(), GetCurrentSubtitleFormat());
|
||||
UiUtil.ShowSubtitle(_subtitle, mediaPlayer, GetCurrentSubtitleFormat());
|
||||
}
|
||||
}
|
||||
@ -31029,7 +31068,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
using (var form = new TextPrompt(LanguageSettings.Current.Main.OpenVideoFile, "Url", string.Empty))
|
||||
using (var form = new TextPrompt(LanguageSettings.Current.Main.OpenVideoFile, "Url", string.Empty, 500))
|
||||
{
|
||||
if (form.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
@ -32381,8 +32420,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if (VideoFileName != null && (VideoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
|
||||
VideoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
|
||||
if (VideoFileNameIsUrl)
|
||||
{
|
||||
MessageBox.Show(LanguageSettings.Current.General.OnlineVideoFeatureNotAvailable);
|
||||
return;
|
||||
|
22
src/ui/Forms/Options/Settings.Designer.cs
generated
22
src/ui/Forms/Options/Settings.Designer.cs
generated
@ -214,6 +214,7 @@
|
||||
this.buttonWaveformsFolderEmpty = new System.Windows.Forms.Button();
|
||||
this.labelWaveformsFolderInfo = new System.Windows.Forms.Label();
|
||||
this.groupBoxWaveformAppearence = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxWaveformAutoGen = new System.Windows.Forms.CheckBox();
|
||||
this.panelWaveformCursorColor = new System.Windows.Forms.Panel();
|
||||
this.buttonWaveformCursorColor = new System.Windows.Forms.Button();
|
||||
this.checkBoxWaveformSnapToSceneChanges = new System.Windows.Forms.CheckBox();
|
||||
@ -414,7 +415,6 @@
|
||||
this.buttonReset = new System.Windows.Forms.Button();
|
||||
this.toolTipContinuationPreview = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
|
||||
this.checkBoxWaveformAutoGen = new System.Windows.Forms.CheckBox();
|
||||
this.panelGeneral.SuspendLayout();
|
||||
this.groupBoxMiscellaneous.SuspendLayout();
|
||||
this.groupBoxGeneralRules.SuspendLayout();
|
||||
@ -2824,6 +2824,16 @@
|
||||
this.groupBoxWaveformAppearence.TabStop = false;
|
||||
this.groupBoxWaveformAppearence.Text = "Waveform appearance";
|
||||
//
|
||||
// checkBoxWaveformAutoGen
|
||||
//
|
||||
this.checkBoxWaveformAutoGen.AutoSize = true;
|
||||
this.checkBoxWaveformAutoGen.Location = new System.Drawing.Point(262, 186);
|
||||
this.checkBoxWaveformAutoGen.Name = "checkBoxWaveformAutoGen";
|
||||
this.checkBoxWaveformAutoGen.Size = new System.Drawing.Size(220, 17);
|
||||
this.checkBoxWaveformAutoGen.TabIndex = 35;
|
||||
this.checkBoxWaveformAutoGen.Text = "Auto gen waveform when opening video";
|
||||
this.checkBoxWaveformAutoGen.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panelWaveformCursorColor
|
||||
//
|
||||
this.panelWaveformCursorColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
@ -4965,16 +4975,6 @@
|
||||
this.toolTipContinuationPreview.InitialDelay = 500;
|
||||
this.toolTipContinuationPreview.ReshowDelay = 100;
|
||||
//
|
||||
// checkBoxWaveformAutoGen
|
||||
//
|
||||
this.checkBoxWaveformAutoGen.AutoSize = true;
|
||||
this.checkBoxWaveformAutoGen.Location = new System.Drawing.Point(262, 188);
|
||||
this.checkBoxWaveformAutoGen.Name = "checkBoxWaveformAutoGen";
|
||||
this.checkBoxWaveformAutoGen.Size = new System.Drawing.Size(220, 17);
|
||||
this.checkBoxWaveformAutoGen.TabIndex = 35;
|
||||
this.checkBoxWaveformAutoGen.Text = "Auto gen waveform when opening video";
|
||||
this.checkBoxWaveformAutoGen.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Settings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -8,11 +8,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public string InputText { get; set; }
|
||||
|
||||
public TextPrompt(string title, string label, string initialText)
|
||||
public TextPrompt(string title, string label, string initialText, int width = 275)
|
||||
{
|
||||
UiUtil.PreInitialize(this);
|
||||
InitializeComponent();
|
||||
UiUtil.FixFonts(this);
|
||||
Width = width;
|
||||
Text = title;
|
||||
labelDescription.Text = label;
|
||||
buttonOK.Text = LanguageSettings.Current.General.Ok;
|
||||
|
@ -7,7 +7,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
public static void Post(this SynchronizationContext context, TimeSpan delay, Action action)
|
||||
{
|
||||
var timer = new System.Windows.Forms.Timer { Interval = delay.Milliseconds };
|
||||
var timer = new System.Windows.Forms.Timer { Interval = (int)delay.TotalMilliseconds };
|
||||
timer.Tick += delegate
|
||||
{
|
||||
action.Invoke();
|
||||
|
Loading…
Reference in New Issue
Block a user