Fix #445 chapters that are script created after the media file is loaded
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
- Fix script compatibility with mordenx and mpv-osc-tethys.
|
- Fix script compatibility with mordenx and mpv-osc-tethys.
|
||||||
- Fix borderless window not resizable with mouse.
|
- Fix borderless window not resizable with mouse.
|
||||||
- Fix start-size=session not working.
|
- Fix start-size=session not working.
|
||||||
|
- Fix chapters that are script created after the media file is loaded.
|
||||||
- Width of command palette slightly increased.
|
- Width of command palette slightly increased.
|
||||||
- libmpv zhongfly 2022-06-19
|
- libmpv zhongfly 2022-06-19
|
||||||
|
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
public static void ShowChapters() => App.InvokeOnMainThread(() =>
|
public static void ShowChapters() => App.InvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
var items = Core.Chapters.Select(i => new CommandPaletteItem(i.Title, i.TimeDisplay, () =>
|
var items = Core.GetChapters().Select(i => new CommandPaletteItem(i.Title, i.TimeDisplay, () =>
|
||||||
Core.CommandV("seek", i.Time.ToString(CultureInfo.InvariantCulture), "absolute")));
|
Core.CommandV("seek", i.Time.ToString(CultureInfo.InvariantCulture), "absolute")));
|
||||||
|
|
||||||
CommandPalette.Instance.SetItems(items);
|
CommandPalette.Instance.SetItems(items);
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ namespace mpvnet
|
|||||||
public AutoResetEvent VideoSizeAutoResetEvent { get; } = new AutoResetEvent(false);
|
public AutoResetEvent VideoSizeAutoResetEvent { get; } = new AutoResetEvent(false);
|
||||||
public IntPtr Handle { get; set; }
|
public IntPtr Handle { get; set; }
|
||||||
public IntPtr NamedHandle { get; set; }
|
public IntPtr NamedHandle { get; set; }
|
||||||
public List<Chapter> Chapters { get; set; } = new List<Chapter>();
|
|
||||||
public List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
public List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||||
public List<TimeSpan> BluRayTitles { get; } = new List<TimeSpan>();
|
public List<TimeSpan> BluRayTitles { get; } = new List<TimeSpan>();
|
||||||
public object MediaTracksLock { get; } = new object();
|
public object MediaTracksLock { get; } = new object();
|
||||||
@@ -1450,25 +1449,26 @@ namespace mpvnet
|
|||||||
else
|
else
|
||||||
MediaTracks = GetTracks();
|
MediaTracks = GetTracks();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lock (Chapters)
|
public List<Chapter> GetChapters() {
|
||||||
|
List<Chapter> chapters = new List<Chapter>();
|
||||||
|
int count = GetPropertyInt("chapter-list/count");
|
||||||
|
|
||||||
|
for (int x = 0; x < count; x++)
|
||||||
{
|
{
|
||||||
Chapters.Clear();
|
string title = GetPropertyString($"chapter-list/{x}/title");
|
||||||
int count = GetPropertyInt("chapter-list/count");
|
double time = GetPropertyDouble($"chapter-list/{x}/time");
|
||||||
|
|
||||||
for (int x = 0; x < count; x++)
|
if (string.IsNullOrEmpty(title) ||
|
||||||
{
|
(title.Length == 12 && title.Contains(":") && title.Contains(".")))
|
||||||
string title = GetPropertyString($"chapter-list/{x}/title");
|
|
||||||
double time = GetPropertyDouble($"chapter-list/{x}/time");
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(title) ||
|
title = "Chapter " + (x + 1);
|
||||||
(title.Length == 12 && title.Contains(":") && title.Contains(".")))
|
|
||||||
|
|
||||||
title = "Chapter " + (x + 1);
|
chapters.Add(new Chapter() { Title = title, Time = time });
|
||||||
|
|
||||||
Chapters.Add(new Chapter() { Title = title, Time = time });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return chapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateExternalTracks()
|
public void UpdateExternalTracks()
|
||||||
|
|||||||
@@ -293,21 +293,18 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (Core.Chapters)
|
var chaptersMenuItem = FindMenuItem("Chapters");
|
||||||
|
|
||||||
|
if (chaptersMenuItem != null)
|
||||||
{
|
{
|
||||||
var chaptersMenuItem = FindMenuItem("Chapters");
|
chaptersMenuItem.Items.Clear();
|
||||||
|
|
||||||
if (chaptersMenuItem != null)
|
foreach (Chapter chapter in Core.GetChapters())
|
||||||
{
|
{
|
||||||
chaptersMenuItem.Items.Clear();
|
var chapterMenuItem = new WpfControls.MenuItem() { Header = chapter.Title };
|
||||||
|
chapterMenuItem.InputGestureText = chapter.TimeDisplay;
|
||||||
foreach (Chapter chapter in Core.Chapters)
|
chapterMenuItem.Click += (sender, args) => Core.CommandV("seek", chapter.Time.ToString(CultureInfo.InvariantCulture), "absolute");
|
||||||
{
|
chaptersMenuItem.Items.Add(chapterMenuItem);
|
||||||
var chapterMenuItem = new WpfControls.MenuItem() { Header = chapter.Title };
|
|
||||||
chapterMenuItem.InputGestureText = chapter.TimeDisplay;
|
|
||||||
chapterMenuItem.Click += (sender, args) => Core.CommandV("seek", chapter.Time.ToString(CultureInfo.InvariantCulture), "absolute");
|
|
||||||
chaptersMenuItem.Items.Add(chapterMenuItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1333,7 +1330,7 @@ namespace mpvnet
|
|||||||
if (CommandPaletteHost == null)
|
if (CommandPaletteHost == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CommandPaletteHost.Width = FontHeight * 27;
|
CommandPaletteHost.Width = FontHeight * 26;
|
||||||
|
|
||||||
if (CommandPaletteHost.Width > ClientSize.Width)
|
if (CommandPaletteHost.Width > ClientSize.Width)
|
||||||
CommandPaletteHost.Width = ClientSize.Width;
|
CommandPaletteHost.Width = ClientSize.Width;
|
||||||
|
|||||||
Reference in New Issue
Block a user