the log feature was not working

This commit is contained in:
Frank Skare
2019-10-13 04:12:48 +02:00
parent f5e0c92824
commit 0cd769fc0c
8 changed files with 56 additions and 24 deletions

View File

@@ -5,11 +5,13 @@
- new: for URLs the media title is shown in the title bar and the info command - new: for URLs the media title is shown in the title bar and the info command
instead of displaying the URL, mpv.conf defaults were changed to use instead of displaying the URL, mpv.conf defaults were changed to use
[protocol.https] osd-playing-msg = '${media-title}' [protocol.https] osd-playing-msg = '${media-title}'
- fix: on the very first start volume was set to 0 and mute was set to yes,
now reasonable defaults are set, volume = 70, mute = no - fix: on the very first start volume was set to 0 and mute was set to yes
- fix: there was a issue fixed with the URL clipboard monitoring - fix: there was a issue fixed with the URL clipboard monitoring
- fix: there was a sound when closed from taskbar due to a exception - fix: there was a sound when closed from taskbar due to a exception
- update: libmpv shinchiro 2019-09-22 - fix: the log feature was not working
- update: libmpv shinchiro 2019-10-06
- update: youtube-dl 2019-10-01 - update: youtube-dl 2019-10-01
### 5.4.1.1 ### 5.4.1.1

View File

@@ -28,9 +28,9 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten
if (Directory.Exists(mp.ConfigFolder + "scripts")) if (Directory.Exists(mp.ConfigFolder + "scripts"))
scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs")); scriptFiles.AddRange(Directory.GetFiles(mp.ConfigFolder + "scripts", "*.cs"));
if (Directory.Exists(PathHelp.StartupPath + "scripts")) if (Directory.Exists(Folder.Startup + "scripts"))
foreach (string path in Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs")) foreach (string path in Directory.GetFiles(Folder.Startup + "scripts", "*.cs"))
scriptFiles.AddRange(Directory.GetFiles(PathHelp.StartupPath + "scripts", "*.cs")); scriptFiles.AddRange(Directory.GetFiles(Folder.Startup + "scripts", "*.cs"));
if (scriptFiles.Count == 0) return; if (scriptFiles.Count == 0) return;
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;

View File

@@ -19,7 +19,7 @@ namespace mpvnet
try try
{ {
AggregateCatalog catalog = new AggregateCatalog(); AggregateCatalog catalog = new AggregateCatalog();
string dir = PathHelp.StartupPath + "Extensions"; string dir = Folder.Startup + "Extensions";
if (Directory.Exists(dir)) if (Directory.Exists(dir))
{ {

View File

@@ -291,8 +291,34 @@ namespace mpvnet
} }
} }
public class Folder
{
public static string Startup { get; } = Application.StartupPath + "\\";
}
public class PathHelp public class PathHelp
{ {
public static string StartupPath { get; } = Application.StartupPath + "\\"; public static string GetBaseName(string value)
{
if (string.IsNullOrEmpty(value))
return "";
int index = value.IndexOf("/");
if (index > -1)
value = value.Substring(index + 1);
index = value.IndexOf("\\");
if (index > -1)
value = value.Substring(index + 1);
index = value.LastIndexOf(".");
if (index > -1)
value = value.Substring(0, index);
return value;
}
} }
} }

View File

@@ -7,7 +7,7 @@ public class Native
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
public static extern bool AttachConsole(int dwProcessId); public static extern bool AttachConsole(int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll")]
public static extern bool FreeConsole(); public static extern bool FreeConsole();
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
@@ -22,7 +22,7 @@ public class Native
[DllImport("user32.dll", CharSet = CharSet.Unicode)] [DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam); public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Unicode)] [DllImport("user32.dll", CharSet = CharSet.Unicode)]
@@ -37,7 +37,7 @@ public class Native
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu); public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
[DllImport("user32.dll", EntryPoint = "GetWindowLong")] [DllImport("user32.dll", EntryPoint = "GetWindowLong")]
@@ -78,7 +78,7 @@ public class Native
Bottom = bottom; Bottom = bottom;
} }
public Rectangle ToRectangle() { return Rectangle.FromLTRB(Left, Top, Right, Bottom); } public Rectangle ToRectangle() => Rectangle.FromLTRB(Left, Top, Right, Bottom);
public Size Size => new Size(Right - Left, Bottom - Top); public Size Size => new Size(Right - Left, Bottom - Top);
public int Width => Right - Left; public int Width => Right - Left;
public int Height => Bottom - Top; public int Height => Bottom - Top;

View File

@@ -10,7 +10,7 @@ namespace mpvnet
{ {
InitializeComponent(); InitializeComponent();
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})"; Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})";
mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(PathHelp.StartupPath + "mpv-1.dll").ToShortDateString()})"; mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})";
} }
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close(); protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();

View File

@@ -134,7 +134,6 @@ namespace mpvnet
StringBuilder buf = new StringBuilder(bufsize); StringBuilder buf = new StringBuilder(bufsize);
Everything_SetSearch(searchtext); Everything_SetSearch(searchtext);
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH); Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH);
Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING);
Everything_Query(true); Everything_Query(true);
for (i = 0; i < Everything_GetNumResults(); i++) for (i = 0; i < Everything_GetNumResults(); i++)

View File

@@ -148,7 +148,7 @@ namespace mpvnet
get { get {
if (_ConfigFolder == null) if (_ConfigFolder == null)
{ {
string portableFolder = PathHelp.StartupPath + "portable_config\\"; string portableFolder = Folder.Startup + "portable_config\\";
_ConfigFolder = portableFolder; _ConfigFolder = portableFolder;
if (!Directory.Exists(_ConfigFolder)) if (!Directory.Exists(_ConfigFolder))
@@ -189,7 +189,7 @@ namespace mpvnet
} }
} }
if (PathHelp.StartupPath == _ConfigFolder) if (Folder.Startup == _ConfigFolder)
{ {
Msg.ShowError("Startup folder and config folder cannot be identical, using portable_config instead."); Msg.ShowError("Startup folder and config folder cannot be identical, using portable_config instead.");
_ConfigFolder = portableFolder; _ConfigFolder = portableFolder;
@@ -236,9 +236,9 @@ namespace mpvnet
public static void LoadMpvScripts() public static void LoadMpvScripts()
{ {
if (Directory.Exists(PathHelp.StartupPath + "Scripts")) if (Directory.Exists(Folder.Startup + "Scripts"))
{ {
string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts"); string[] startupScripts = Directory.GetFiles(Folder.Startup + "Scripts");
foreach (string path in startupScripts) foreach (string path in startupScripts)
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path))) if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
@@ -250,9 +250,9 @@ namespace mpvnet
public static void LoadScripts() public static void LoadScripts()
{ {
if (Directory.Exists(PathHelp.StartupPath + "Scripts")) if (Directory.Exists(Folder.Startup + "Scripts"))
{ {
foreach (string scriptPath in Directory.GetFiles(PathHelp.StartupPath + "Scripts")) foreach (string scriptPath in Directory.GetFiles(Folder.Startup + "Scripts"))
{ {
if (KnownScripts.Contains(Path.GetFileName(scriptPath))) if (KnownScripts.Contains(Path.GetFileName(scriptPath)))
{ {
@@ -329,7 +329,10 @@ namespace mpvnet
} }
VideoSizeAutoResetEvent.Set(); VideoSizeAutoResetEvent.Set();
Task.Run(new Action(() => ReadMetaData())); Task.Run(new Action(() => ReadMetaData()));
WriteHistory(get_property_string("path")); string path = mp.get_property_string("path");
if (path.Contains("://"))
path = mp.get_property_string("media-title");
WriteHistory(path);
FileLoaded?.Invoke(); FileLoaded?.Invoke();
break; break;
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED: case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
@@ -750,12 +753,14 @@ namespace mpvnet
static void WriteHistory(string path) static void WriteHistory(string path)
{ {
if (!File.Exists(ConfigFolder + "history.txt") || !File.Exists(path)) return; if (!File.Exists(ConfigFolder + "history.txt"))
return;
int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes); int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes);
if (File.Exists(LastHistoryPath) && totalMinutes > 1) if (PathHelp.GetBaseName(LastHistoryPath) != "" && totalMinutes > 1)
File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) + File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) +
" " + totalMinutes.ToString().PadLeft(3) + " " + Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n"); " " + totalMinutes.ToString().PadLeft(3) + " " + PathHelp.GetBaseName(LastHistoryPath) + "\r\n");
LastHistoryPath = path; LastHistoryPath = path;
LastHistoryStartDateTime = DateTime.Now; LastHistoryStartDateTime = DateTime.Now;