Skip to content

Commit

Permalink
window title fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Jul 2, 2022
1 parent 1015f87 commit 03b7753
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Misc/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ public void LoadFiles(string[] files, bool loadFolder, bool append)
{
string file = files[i];

if (file.Contains("|"))
file = file.Substring(0, file.IndexOf("|"));

if (file.Ext() == "avs")
LoadAviSynth();

Expand Down
27 changes: 24 additions & 3 deletions src/WinForms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public MainForm()

Core.FileLoaded += Core_FileLoaded;
Core.Pause += Core_Pause;
Core.PlaylistPosChanged += (value) => SetTitle();
Core.PlaylistPosChanged += Core_PlaylistPosChanged;
Core.ScaleWindow += Core_ScaleWindow;
Core.Seek += () => UpdateProgressBar();
Core.ShowMenu += Core_ShowMenu;
Expand Down Expand Up @@ -118,6 +118,12 @@ public MainForm()
}
}

private void Core_PlaylistPosChanged(int pos)
{
if (pos == -1)
SetTitle();
}

void Init()
{
Core.Init(Handle);
Expand Down Expand Up @@ -720,7 +726,7 @@ public void BuildMenu()
void Core_FileLoaded()
{
BeginInvoke(new Action(() => {
Text = Core.Expand(Title);
SetTitleInternal();
int interval = (int)(Core.Duration.TotalMilliseconds / 100);
Expand Down Expand Up @@ -759,7 +765,22 @@ void Core_FileLoaded()
}
}

void SetTitle() => BeginInvoke(new Action(() => Text = Core.Expand(Title)));
void SetTitle() => BeginInvoke(new Action(() => SetTitleInternal()));

void SetTitleInternal()
{
string title = Title;

if (title == "${filename}" && Core.Path.ContainsEx("://"))
title = "${media-title}";

string text = Core.Expand(title);

if (text == "(unavailable)")
text = "mpv.net";

Text = text;
}

public void Voodoo()
{
Expand Down

0 comments on commit 03b7753

Please sign in to comment.