diff --git a/Other/mpv-dll-32.zip b/Other/mpv-dll-32.zip new file mode 100644 index 000000000..803f7904b Binary files /dev/null and b/Other/mpv-dll-32.zip differ diff --git a/Other/mpv-dll-64.zip b/Other/mpv-dll-64.zip new file mode 100644 index 000000000..55caec067 Binary files /dev/null and b/Other/mpv-dll-64.zip differ diff --git a/src/Forms/SettingsMpv.Designer.cs b/src/Forms/SettingsMpv.Designer.cs new file mode 100644 index 000000000..40f774e1a --- /dev/null +++ b/src/Forms/SettingsMpv.Designer.cs @@ -0,0 +1,137 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class SettingsMpv + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonDownload = new System.Windows.Forms.Button(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelPleaseWait = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonDownload + // + this.buttonDownload.Location = new System.Drawing.Point(12, 24); + this.buttonDownload.Name = "buttonDownload"; + this.buttonDownload.Size = new System.Drawing.Size(159, 23); + this.buttonDownload.TabIndex = 0; + this.buttonDownload.Text = "Download mpv dll"; + this.buttonDownload.UseVisualStyleBackColor = true; + this.buttonDownload.Click += new System.EventHandler((sender, e) => this.buttonDownload_Click(sender, e)); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "direct3d_shaders", + "direct3d ", + "sdl", + "vaapi"}); + this.comboBox1.Location = new System.Drawing.Point(12, 109); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(186, 21); + this.comboBox1.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 93); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Video option"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(126, 165); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 21); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(210, 165); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 21); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // labelPleaseWait + // + this.labelPleaseWait.AutoSize = true; + this.labelPleaseWait.Location = new System.Drawing.Point(12, 50); + this.labelPleaseWait.Name = "labelPleaseWait"; + this.labelPleaseWait.Size = new System.Drawing.Size(70, 13); + this.labelPleaseWait.TabIndex = 13; + this.labelPleaseWait.Text = "Please wait..."; + // + // SettingsMpv + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(297, 198); + this.Controls.Add(this.labelPleaseWait); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.buttonDownload); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SettingsMpv"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "SettingsMpv"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonDownload; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelPleaseWait; + } +} \ No newline at end of file diff --git a/src/Forms/SettingsMpv.cs b/src/Forms/SettingsMpv.cs new file mode 100644 index 000000000..84fd9b7e1 --- /dev/null +++ b/src/Forms/SettingsMpv.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class SettingsMpv : Form + { + public SettingsMpv() + { + InitializeComponent(); + } + + private void buttonDownload_Click(object sender, EventArgs e) + { + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + buttonOK.Enabled = false; + buttonDownload.Enabled = false; + Refresh(); + Cursor = Cursors.WaitCursor; + + string url = "https://github.com/SubtitleEdit/subtitleedit/raw/master/Other/mpv-dll-64.zip"; + if (IntPtr.Size*8 == 32) + { + url = "https://github.com/SubtitleEdit/subtitleedit/raw/master/Other/mpv-dll-32.zip"; + } + + var wc = new WebClient { Proxy = Utilities.GetProxy() }; + wc.DownloadDataCompleted += wc_DownloadDataCompleted; + wc.DownloadDataAsync(new Uri(url)); + Cursor = Cursors.Default; + } + catch (Exception exception) + { + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + + private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) + { + if (e.Error != null ) + { + MessageBox.Show("Unable to download mpv - please re-try later!"); + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + Cursor = Cursors.Default; + return; + } + + string dictionaryFolder = Utilities.DictionaryFolder; + using (var ms = new MemoryStream(e.Result)) + using (ZipExtractor zip = ZipExtractor.Open(ms)) + { + List dir = zip.ReadCentralDir(); + foreach (ZipExtractor.ZipFileEntry entry in dir) + { + if (entry.FilenameInZip.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) + { + string fileName = Path.GetFileName(entry.FilenameInZip); + string path = Path.Combine(dictionaryFolder, fileName); + zip.ExtractFile(entry, path); + } + } + } + + Cursor = Cursors.Default; + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + MessageBox.Show("mpv downloaded OK"); + } + + + } +} diff --git a/src/Forms/SettingsMpv.resx b/src/Forms/SettingsMpv.resx new file mode 100644 index 000000000..29dcb1b3a --- /dev/null +++ b/src/Forms/SettingsMpv.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/SubtitleEdit.csproj b/src/SubtitleEdit.csproj index 312870818..0d11a71cf 100644 --- a/src/SubtitleEdit.csproj +++ b/src/SubtitleEdit.csproj @@ -574,6 +574,12 @@ Settings.cs + + Form + + + SettingsMpv.cs + Form @@ -1121,6 +1127,9 @@ Settings.cs Designer + + SettingsMpv.cs + SetVideoOffset.cs