mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-02-01 05:21:40 +01:00
Added preview text inside video for libmpv
This commit is contained in:
parent
6a21b64a7a
commit
2e744f246a
@ -1741,6 +1741,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<MpcHcDescription>Media Player Classic - Home Cinema</MpcHcDescription>
|
||||
<MpvPlayer>mpv</MpvPlayer>
|
||||
<MpvPlayerDescription>https://mpv.io/ - free, open source, and cross-platform media player</MpvPlayerDescription>
|
||||
<MpvHandlesPreviewText>mpv handles preview text</MpvHandlesPreviewText>
|
||||
<VlcMediaPlayer>VLC media player</VlcMediaPlayer>
|
||||
<VlcMediaPlayerDescription>libvlc.dll from VLC media player 1.1.0 or newer</VlcMediaPlayerDescription>
|
||||
<VlcBrowseToLabel>VLC path (only needed if you're using the portable version of VLC)</VlcBrowseToLabel>
|
||||
|
@ -2025,6 +2025,7 @@ can edit in same subtitle file (collaboration)",
|
||||
MpcHcDescription = "Media Player Classic - Home Cinema",
|
||||
MpvPlayer = "mpv",
|
||||
MpvPlayerDescription = "https://mpv.io/ - free, open source, and cross-platform media player",
|
||||
MpvHandlesPreviewText = "mpv handles preview text",
|
||||
VlcMediaPlayer = "VLC media player",
|
||||
VlcMediaPlayerDescription = "libvlc.dll from VLC media player 1.1.0 or newer",
|
||||
VlcBrowseToLabel = "VLC path (only needed if you're using the portable version of VLC)",
|
||||
|
@ -4672,6 +4672,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "Settings/MpvPlayerDescription":
|
||||
language.Settings.MpvPlayerDescription = reader.Value;
|
||||
break;
|
||||
case "Settings/MpvHandlesPreviewText":
|
||||
language.Settings.MpvHandlesPreviewText = reader.Value;
|
||||
break;
|
||||
case "Settings/VlcMediaPlayer":
|
||||
language.Settings.VlcMediaPlayer = reader.Value;
|
||||
break;
|
||||
|
@ -1904,6 +1904,7 @@
|
||||
public string MpcHcDescription { get; set; }
|
||||
public string MpvPlayer { get; set; }
|
||||
public string MpvPlayerDescription { get; set; }
|
||||
public string MpvHandlesPreviewText { get; set; }
|
||||
public string VlcMediaPlayer { get; set; }
|
||||
public string VlcMediaPlayerDescription { get; set; }
|
||||
public string VlcBrowseToLabel { get; set; }
|
||||
|
@ -589,6 +589,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public string VlcLocation { get; set; }
|
||||
public string VlcLocationRelative { get; set; }
|
||||
public string MpvVideoOutput { get; set; }
|
||||
public bool MpvHandlesPreviewText { get; set; }
|
||||
public string MpcHcLocation { get; set; }
|
||||
public bool UseFFmpegForWaveExtraction { get; set; }
|
||||
public string FFmpegLocation { get; set; }
|
||||
@ -686,6 +687,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
ListViewColumnsRememberSize = true;
|
||||
VlcWaveTranscodeSettings = "acodec=s16l"; // "acodec=s16l,channels=1,ab=64,samplerate=8000";
|
||||
MpvVideoOutput = Configuration.IsRunningOnLinux() ? "vaapi" : "opengl";
|
||||
MpvHandlesPreviewText = true;
|
||||
UseTimeFormatHHMMSSFF = false;
|
||||
ClearStatusBarAfterSeconds = 10;
|
||||
MoveVideo100Or500MsPlaySmallSample = false;
|
||||
@ -1629,6 +1631,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
subNode = node.SelectSingleNode("MpvVideoOutput");
|
||||
if (subNode != null)
|
||||
settings.General.MpvVideoOutput = subNode.InnerText.Trim();
|
||||
subNode = node.SelectSingleNode("MpvHandlesPreviewText");
|
||||
if (subNode != null)
|
||||
settings.General.MpvHandlesPreviewText = Convert.ToBoolean(subNode.InnerText.Trim());
|
||||
subNode = node.SelectSingleNode("MpcHcLocation");
|
||||
if (subNode != null)
|
||||
settings.General.MpcHcLocation = subNode.InnerText.Trim();
|
||||
@ -3156,6 +3161,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
textWriter.WriteElementString("VlcLocation", settings.General.VlcLocation);
|
||||
textWriter.WriteElementString("VlcLocationRelative", settings.General.VlcLocationRelative);
|
||||
textWriter.WriteElementString("MpvVideoOutput", settings.General.MpvVideoOutput);
|
||||
textWriter.WriteElementString("MpvHandlesPreviewText", settings.General.MpvHandlesPreviewText.ToString());
|
||||
textWriter.WriteElementString("MpcHcLocation", settings.General.MpcHcLocation);
|
||||
textWriter.WriteElementString("UseFFmpegForWaveExtraction", settings.General.UseFFmpegForWaveExtraction.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("FFmpegLocation", settings.General.FFmpegLocation);
|
||||
|
@ -68,6 +68,11 @@ namespace Nikse.SubtitleEdit.Core
|
||||
FileName = subtitle.FileName;
|
||||
}
|
||||
|
||||
public Subtitle(List<Paragraph> paragraphs) : this()
|
||||
{
|
||||
_paragraphs = paragraphs;
|
||||
}
|
||||
|
||||
public List<Paragraph> Paragraphs
|
||||
{
|
||||
get
|
||||
|
@ -2,8 +2,10 @@
|
||||
using Nikse.SubtitleEdit.Logic.VideoPlayers;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Controls
|
||||
{
|
||||
@ -48,13 +50,19 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
_videoPlayer = value;
|
||||
if (_videoPlayer != null)
|
||||
SetPlayerName(_videoPlayer.PlayerName);
|
||||
if (_videoPlayer is LibMpvDynamic && Configuration.Settings.General.MpvHandlesPreviewText)
|
||||
{
|
||||
_subtitlesHeight = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitlesHeight = 57;
|
||||
}
|
||||
_mpvTextFileName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public RichTextBoxViewOnly TextBox
|
||||
{
|
||||
get { return _subtitleTextBox; }
|
||||
}
|
||||
public RichTextBoxViewOnly TextBox => _subtitleTextBox;
|
||||
|
||||
public int VideoWidth { get; set; }
|
||||
public int VideoHeight { get; set; }
|
||||
@ -63,7 +71,8 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
private double? _muteOldVolume;
|
||||
private readonly System.ComponentModel.ComponentResourceManager _resources;
|
||||
private int _controlsHeight = 47;
|
||||
private const int SubtitlesHeight = 57;
|
||||
private const int OriginalSubtitlesHeight = 57;
|
||||
private int _subtitlesHeight = OriginalSubtitlesHeight;
|
||||
private readonly Color _backgroundColor = Color.FromArgb(18, 18, 18);
|
||||
private Panel _panelcontrols;
|
||||
|
||||
@ -250,7 +259,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
|
||||
private Control MakeSubtitlesPanel()
|
||||
{
|
||||
_panelSubtitle = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0, Height = SubtitlesHeight + 1 };
|
||||
_panelSubtitle = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0, Height = _subtitlesHeight + 1 };
|
||||
_subtitleTextBox = new RichTextBoxViewOnly();
|
||||
_panelSubtitle.Controls.Add(_subtitleTextBox);
|
||||
_subtitleTextBox.BackColor = _backgroundColor;
|
||||
@ -280,12 +289,75 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
|
||||
public Paragraph LastParagraph { get; private set; }
|
||||
|
||||
public void SetSubtitleText(string text, Paragraph p)
|
||||
public void SetSubtitleText(string text, Paragraph p, Subtitle subtitle)
|
||||
{
|
||||
var mpv = VideoPlayer as LibMpvDynamic;
|
||||
if (mpv != null && Configuration.Settings.General.MpvHandlesPreviewText)
|
||||
{
|
||||
RefreshMpv(mpv, subtitle);
|
||||
if (_subtitleTextBox.Text.Length > 0)
|
||||
_subtitleTextBox.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
SubtitleText = text;
|
||||
LastParagraph = p;
|
||||
}
|
||||
|
||||
private Subtitle _subtitlePrev;
|
||||
private static string _mpvTextOld = string.Empty;
|
||||
private string _mpvTextFileName;
|
||||
private void RefreshMpv(LibMpvDynamic mpv, Subtitle subtitle)
|
||||
{
|
||||
if (subtitle == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
SubtitleFormat format;
|
||||
if (subtitle.Header != null && subtitle.Header.Contains("[V4+ Styles]"))
|
||||
format = new AdvancedSubStationAlpha();
|
||||
else
|
||||
format = new SubRip();
|
||||
string text = subtitle.ToText(format);
|
||||
if (text != _mpvTextOld || _mpvTextFileName == null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mpvTextFileName) || _subtitlePrev != subtitle)
|
||||
{
|
||||
DeleteTempMpvFileName();
|
||||
_mpvTextFileName = Path.GetTempFileName() + format.Extension;
|
||||
File.WriteAllText(_mpvTextFileName, text);
|
||||
mpv.LoadSubtitle(_mpvTextFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllText(_mpvTextFileName, text);
|
||||
mpv.ReloadSubtitle();
|
||||
}
|
||||
_mpvTextOld = text;
|
||||
}
|
||||
_subtitlePrev = subtitle;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteTempMpvFileName()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(_mpvTextFileName))
|
||||
{
|
||||
File.Delete(_mpvTextFileName);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
public string SubtitleText
|
||||
{
|
||||
get
|
||||
@ -847,12 +919,11 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
public void VideoPlayerContainerResize(object sender, EventArgs e)
|
||||
{
|
||||
_controlsHeight = _pictureBoxBackground.Height;
|
||||
PanelPlayer.Height = Height - (_controlsHeight + SubtitlesHeight);
|
||||
PanelPlayer.Height = Height - (_controlsHeight + _subtitlesHeight);
|
||||
PanelPlayer.Width = Width;
|
||||
if (_videoPlayer != null)
|
||||
_videoPlayer.Resize(PanelPlayer.Width, PanelPlayer.Height);
|
||||
_videoPlayer?.Resize(PanelPlayer.Width, PanelPlayer.Height);
|
||||
|
||||
_panelSubtitle.Top = Height - (_controlsHeight + SubtitlesHeight);
|
||||
_panelSubtitle.Top = Height - (_controlsHeight + _subtitlesHeight);
|
||||
_panelSubtitle.Width = Width;
|
||||
|
||||
_panelcontrols.Top = Height - _controlsHeight + 2;
|
||||
@ -865,6 +936,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
|
||||
_labelTimeCode.Left = Width - 170;
|
||||
_labelVideoPlayerName.Left = Width - _labelVideoPlayerName.Width - 3;
|
||||
_mpvTextFileName = null;
|
||||
}
|
||||
|
||||
#region PlayPauseButtons
|
||||
@ -1360,13 +1432,7 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPaused
|
||||
{
|
||||
get
|
||||
{
|
||||
return VideoPlayer?.IsPaused == true;
|
||||
}
|
||||
}
|
||||
public bool IsPaused => VideoPlayer?.IsPaused == true;
|
||||
|
||||
public double Volume
|
||||
{
|
||||
@ -1462,5 +1528,11 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
|
||||
#endregion VideoPlayer functions
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
DeleteTempMpvFileName();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4043,8 +4043,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
UiUtil.InitializeVideoPlayerAndContainer(_videoFileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded);
|
||||
}
|
||||
}
|
||||
mediaPlayer.VideoPlayerContainerResize(null, null);
|
||||
|
||||
if (!string.IsNullOrEmpty(_videoFileName) &&
|
||||
if (!string.IsNullOrEmpty(_videoFileName) &&
|
||||
(oldVideoPlayer != Configuration.Settings.General.VideoPlayer && mediaPlayer.VideoPlayer != null) ||
|
||||
(oldMpvVideoOutput != Configuration.Settings.General.MpvVideoOutput && Configuration.Settings.General.VideoPlayer.Equals("MPV", StringComparison.OrdinalIgnoreCase))
|
||||
)
|
||||
@ -4094,10 +4095,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private int ShowSubtitle()
|
||||
{
|
||||
if (_splitDualSami)
|
||||
return UiUtil.ShowSubtitle(_subtitle.Paragraphs, _subtitleAlternate, mediaPlayer);
|
||||
return UiUtil.ShowSubtitle(_subtitle, _subtitleAlternate, mediaPlayer);
|
||||
if (SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable)
|
||||
return UiUtil.ShowSubtitle(_subtitleAlternate.Paragraphs, mediaPlayer);
|
||||
return UiUtil.ShowSubtitle(_subtitle.Paragraphs, mediaPlayer);
|
||||
return UiUtil.ShowSubtitle(_subtitleAlternate, mediaPlayer);
|
||||
return UiUtil.ShowSubtitle(_subtitle, mediaPlayer);
|
||||
}
|
||||
|
||||
private static void TryLoadIcon(ToolStripButton button, string iconName)
|
||||
@ -13695,16 +13696,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ShowSubtitleTimer.Start();
|
||||
}
|
||||
|
||||
private void videoModeHiddenToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
HideVideoPlayer();
|
||||
}
|
||||
|
||||
private void createadjustLinesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowVideoPlayer();
|
||||
}
|
||||
|
||||
private void HideVideoPlayer()
|
||||
{
|
||||
mediaPlayer.Pause();
|
||||
@ -14771,7 +14762,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
|
||||
int index = SubtitleListview1.SelectedItems[0].Index;
|
||||
if (!mediaPlayer.IsPaused)
|
||||
videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay/TimeCode.BaseUnit;
|
||||
videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit;
|
||||
var tc = TimeCode.FromSeconds(videoPosition);
|
||||
timeUpDownStartTime.TimeCode = tc;
|
||||
|
||||
@ -15917,7 +15908,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
startSeconds = Math.Max(startSeconds, _endSeconds - 1.0);
|
||||
}
|
||||
mediaPlayer.CurrentPosition = startSeconds;
|
||||
UiUtil.ShowSubtitle(_subtitle.Paragraphs, mediaPlayer);
|
||||
UiUtil.ShowSubtitle(_subtitle, mediaPlayer);
|
||||
mediaPlayer.Play();
|
||||
}
|
||||
}
|
||||
|
@ -192,9 +192,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
pos = videoPlayerContainer1.CurrentPosition;
|
||||
}
|
||||
if (pos != _lastPosition)
|
||||
if (Math.Abs(pos - _lastPosition) > 0.01)
|
||||
{
|
||||
UiUtil.ShowSubtitle(_subtitle.Paragraphs, videoPlayerContainer1);
|
||||
UiUtil.ShowSubtitle(_subtitle, videoPlayerContainer1);
|
||||
timeUpDownLine.TimeCode = TimeCode.FromSeconds(pos);
|
||||
_lastPosition = pos;
|
||||
}
|
||||
|
13
src/Forms/Settings.Designer.cs
generated
13
src/Forms/Settings.Designer.cs
generated
@ -327,6 +327,7 @@
|
||||
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.openFileDialogFFmpeg = new System.Windows.Forms.OpenFileDialog();
|
||||
this.checkBoxMpvHandlesPreviewText = new System.Windows.Forms.CheckBox();
|
||||
this.tabControlSettings.SuspendLayout();
|
||||
this.tabPageGeneral.SuspendLayout();
|
||||
this.groupBoxMiscellaneous.SuspendLayout();
|
||||
@ -1920,6 +1921,7 @@
|
||||
//
|
||||
this.groupBoxVideoEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxVideoEngine.Controls.Add(this.checkBoxMpvHandlesPreviewText);
|
||||
this.groupBoxVideoEngine.Controls.Add(this.labelMpvSettings);
|
||||
this.groupBoxVideoEngine.Controls.Add(this.buttonMpvSettings);
|
||||
this.groupBoxVideoEngine.Controls.Add(this.labelPlatform);
|
||||
@ -3909,6 +3911,16 @@
|
||||
//
|
||||
this.openFileDialogFFmpeg.FileName = "openFileDialog1";
|
||||
//
|
||||
// checkBoxMpvHandlesPreviewText
|
||||
//
|
||||
this.checkBoxMpvHandlesPreviewText.AutoSize = true;
|
||||
this.checkBoxMpvHandlesPreviewText.Location = new System.Drawing.Point(570, 90);
|
||||
this.checkBoxMpvHandlesPreviewText.Name = "checkBoxMpvHandlesPreviewText";
|
||||
this.checkBoxMpvHandlesPreviewText.Size = new System.Drawing.Size(150, 17);
|
||||
this.checkBoxMpvHandlesPreviewText.TabIndex = 31;
|
||||
this.checkBoxMpvHandlesPreviewText.Text = "mpv handles preview text";
|
||||
this.checkBoxMpvHandlesPreviewText.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Settings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -4330,5 +4342,6 @@
|
||||
private System.Windows.Forms.CheckBox checkBoxWaveformShowCps;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownMaxWordsMin;
|
||||
private System.Windows.Forms.Label labelMaxWordsPerMin;
|
||||
private System.Windows.Forms.CheckBox checkBoxMpvHandlesPreviewText;
|
||||
}
|
||||
}
|
@ -148,6 +148,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (Logic.VideoPlayers.MpcHC.MpcHc.GetMpcHcFileName() == null)
|
||||
radioButtonVideoPlayerMpcHc.Enabled = false;
|
||||
RefreshMpvSettings();
|
||||
checkBoxMpvHandlesPreviewText.Checked = gs.MpvHandlesPreviewText;
|
||||
|
||||
textBoxVlcPath.Text = gs.VlcLocation;
|
||||
textBoxVlcPath.Left = labelVideoPlayerVLC.Left + labelVideoPlayerVLC.Width + 5;
|
||||
@ -360,6 +361,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelVideoPlayerMPlayer.Text = language.MpvPlayerDescription;
|
||||
buttonMpvSettings.Left = labelVideoPlayerMPlayer.Left + labelVideoPlayerMPlayer.Width + 5;
|
||||
labelMpvSettings.Left = buttonMpvSettings.Left + buttonMpvSettings.Width + 5;
|
||||
checkBoxMpvHandlesPreviewText.Text = language.MpvHandlesPreviewText;
|
||||
|
||||
radioButtonVideoPlayerVLC.Text = language.VlcMediaPlayer;
|
||||
labelVideoPlayerVLC.Text = language.VlcMediaPlayerDescription;
|
||||
gs.VlcLocation = textBoxVlcPath.Text;
|
||||
@ -1137,7 +1140,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
gs.VideoPlayer = "VLC";
|
||||
else
|
||||
gs.VideoPlayer = "DirectShow";
|
||||
|
||||
gs.MpvHandlesPreviewText = checkBoxMpvHandlesPreviewText.Checked;
|
||||
gs.VlcLocation = textBoxVlcPath.Text;
|
||||
|
||||
gs.VideoPlayerShowStopButton = checkBoxVideoPlayerShowStopButton.Checked;
|
||||
@ -2323,7 +2326,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void RefreshMpvSettings()
|
||||
{
|
||||
radioButtonVideoPlayerMPV.Enabled = LibMpvDynamic.IsInstalled;
|
||||
if (Configuration.IsRunningOnLinux() && (Configuration.Settings.General.MpvVideoOutput == "direct3d_shaders"))
|
||||
if (Configuration.IsRunningOnLinux() && Configuration.Settings.General.MpvVideoOutput.StartsWith("direct3d"))
|
||||
labelMpvSettings.Text = "--vo=vaapi";
|
||||
else
|
||||
labelMpvSettings.Text = "--vo=" + Configuration.Settings.General.MpvVideoOutput;
|
||||
|
@ -255,7 +255,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MediaPlayerStart.CurrentPosition = _startGoBackPosition;
|
||||
_startStopPosition = -1;
|
||||
}
|
||||
UiUtil.ShowSubtitle(_paragraphs, MediaPlayerStart);
|
||||
UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerStart);
|
||||
}
|
||||
if (!MediaPlayerEnd.IsPaused)
|
||||
{
|
||||
@ -266,7 +266,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MediaPlayerEnd.CurrentPosition = _endGoBackPosition;
|
||||
_endStopPosition = -1;
|
||||
}
|
||||
UiUtil.ShowSubtitle(_paragraphs, MediaPlayerEnd);
|
||||
UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -453,8 +453,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (mediaPlayer.CurrentPosition > seconds)
|
||||
mediaPlayer.CurrentPosition -= seconds;
|
||||
else
|
||||
mediaPlayer.CurrentPosition = 0;
|
||||
UiUtil.ShowSubtitle(_paragraphs, mediaPlayer);
|
||||
mediaPlayer.CurrentPosition = 0;
|
||||
UiUtil.ShowSubtitle(new Subtitle( _paragraphs), mediaPlayer);
|
||||
}
|
||||
|
||||
private void ButtonStartHalfASecondBackClick(object sender, EventArgs e)
|
||||
|
@ -42,66 +42,45 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
private static VideoInfo TryReadVideoInfoViaDirectShow(string fileName)
|
||||
{
|
||||
return QuartsPlayer.GetVideoInfo(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetSubtitleIndex(List<Paragraph> paragraphs, VideoPlayerContainer videoPlayerContainer)
|
||||
{
|
||||
if (videoPlayerContainer.VideoPlayer != null)
|
||||
{
|
||||
double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 5;
|
||||
for (int i = 0; i < paragraphs.Count; i++)
|
||||
{
|
||||
var p = paragraphs[i];
|
||||
if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && p.EndTime.TotalMilliseconds > positionInMilliseconds)
|
||||
{
|
||||
bool isInfo = p == paragraphs[0] && (p.StartTime.TotalMilliseconds == 0 && p.Duration.TotalMilliseconds == 0 || p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds);
|
||||
if (!isInfo)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
|
||||
videoPlayerContainer.SetSubtitleText(string.Empty, null);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int ShowSubtitle(List<Paragraph> paragraphs, VideoPlayerContainer videoPlayerContainer)
|
||||
public static int ShowSubtitle(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer)
|
||||
{
|
||||
if (videoPlayerContainer.VideoPlayer != null)
|
||||
{
|
||||
double positionInMilliseconds = (videoPlayerContainer.CurrentPosition * TimeCode.BaseUnit) + 5;
|
||||
for (int i = 0; i < paragraphs.Count; i++)
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = paragraphs[i];
|
||||
var p = subtitle.Paragraphs[i];
|
||||
if (p.StartTime.TotalMilliseconds <= positionInMilliseconds &&
|
||||
p.EndTime.TotalMilliseconds > positionInMilliseconds)
|
||||
{
|
||||
string text = p.Text.Replace("|", Environment.NewLine);
|
||||
bool isInfo = p == paragraphs[0] && (p.StartTime.TotalMilliseconds == 0 && p.Duration.TotalMilliseconds == 0 || p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds);
|
||||
bool isInfo = p == subtitle.Paragraphs[0] && (p.StartTime.TotalMilliseconds == 0 && p.Duration.TotalMilliseconds == 0 || p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds);
|
||||
if (!isInfo)
|
||||
{
|
||||
if (videoPlayerContainer.LastParagraph != p)
|
||||
videoPlayerContainer.SetSubtitleText(text, p);
|
||||
videoPlayerContainer.SetSubtitleText(text, p, subtitle);
|
||||
else if (videoPlayerContainer.SubtitleText != text)
|
||||
videoPlayerContainer.SetSubtitleText(text, p);
|
||||
videoPlayerContainer.SetSubtitleText(text, p, subtitle);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
|
||||
videoPlayerContainer.SetSubtitleText(string.Empty, null);
|
||||
videoPlayerContainer.SetSubtitleText(string.Empty, null, subtitle);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int ShowSubtitle(List<Paragraph> paragraphs, Subtitle original, VideoPlayerContainer videoPlayerContainer)
|
||||
public static int ShowSubtitle(Subtitle subtitle, Subtitle original, VideoPlayerContainer videoPlayerContainer)
|
||||
{
|
||||
if (videoPlayerContainer.VideoPlayer != null)
|
||||
{
|
||||
double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 15;
|
||||
for (int i = 0; i < paragraphs.Count; i++)
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = paragraphs[i];
|
||||
var p = subtitle.Paragraphs[i];
|
||||
if (p.StartTime.TotalMilliseconds <= positionInMilliseconds &&
|
||||
p.EndTime.TotalMilliseconds > positionInMilliseconds)
|
||||
{
|
||||
@ -111,20 +90,20 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (op != null)
|
||||
text = text + Environment.NewLine + Environment.NewLine + op.Text.Replace("|", Environment.NewLine);
|
||||
|
||||
bool isInfo = p == paragraphs[0] && p.StartTime.TotalMilliseconds == 0 && positionInMilliseconds > 3000;
|
||||
bool isInfo = p == subtitle.Paragraphs[0] && p.StartTime.TotalMilliseconds == 0 && positionInMilliseconds > 3000;
|
||||
if (!isInfo)
|
||||
{
|
||||
if (videoPlayerContainer.LastParagraph != p)
|
||||
videoPlayerContainer.SetSubtitleText(text, p);
|
||||
videoPlayerContainer.SetSubtitleText(text, p, subtitle);
|
||||
else if (videoPlayerContainer.SubtitleText != text)
|
||||
videoPlayerContainer.SetSubtitleText(text, p);
|
||||
videoPlayerContainer.SetSubtitleText(text, p, subtitle);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
|
||||
videoPlayerContainer.SetSubtitleText(string.Empty, null);
|
||||
videoPlayerContainer.SetSubtitleText(string.Empty, null, subtitle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -341,6 +341,15 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadSubtitle(string fileName)
|
||||
{
|
||||
DoMpvCommand("sub-add", fileName, "select");
|
||||
}
|
||||
|
||||
public void ReloadSubtitle()
|
||||
{
|
||||
DoMpvCommand("sub-reload");
|
||||
}
|
||||
|
||||
public static bool IsInstalled
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user