Compare commits

..

23 Commits
5.1 ... 5.4.1

Author SHA1 Message Date
Frank Skare
0a28f13d51 5.4 Release 2019-09-05 19:00:54 +02:00
Frank Skare
9f3a1da931 fix relative file path not found 2019-09-05 09:12:19 +02:00
Frank Skare
05874ad6be update changelog 2019-09-05 08:15:13 +02:00
Frank Skare
078e8046bd added taskbar-progress implementation 2019-09-05 06:20:44 +02:00
Frank Skare
b07901485e fixed history being written even when history file wasn't created prior 2019-08-28 09:36:10 +02:00
Frank Skare
a37cbef8a8 long file names work now even if not enabled by the OS 2019-08-21 17:21:04 +02:00
Frank Skare
8debcc171c added new setting to start with maximized window 2019-08-21 16:52:09 +02:00
Frank Skare
e230f0f474 osc=yes and input-media-keys=yes was enforced, can now be disabled in mpv.conf 2019-08-16 19:37:07 +02:00
Frank Skare
558bd67591 update readme 2019-08-11 05:53:42 +02:00
Frank Skare
a7e4892acf update readme 2019-08-11 05:53:05 +02:00
Frank Skare
a0ba69c1aa readme update 2019-08-11 05:52:22 +02:00
Frank Skare
1e7e80577d 5.3 Release 2019-08-11 05:47:17 +02:00
Frank Skare
2177308b02 new config setting recent-count added 2019-08-11 04:58:42 +02:00
Frank Skare
a8c2409ed1 new menu items added to navigate to the first and last playlist position 2019-08-09 01:59:20 +02:00
Frank Skare
1ef9e64a41 scale, cscale, dscale defaults have been set to spline36 2019-08-08 19:07:27 +02:00
Frank Skare
f0546485cf Open > Open DVD/Blu-ray Drive/Folder 2019-08-08 18:45:34 +02:00
Frank Skare
032e91e4b4 mpv setting osd-scale-by-window added to config dialog 2019-08-08 03:31:57 +02:00
Frank Skare
1447636eb7 fixed race condition causing various features to fail 2019-08-07 13:16:05 +02:00
Frank Skare
966f96a02b 5.2 Release 2019-08-06 18:44:40 +02:00
Frank Skare
954c014708 bug fix for logo not shown on start 2019-08-06 01:49:51 +02:00
Frank Skare
ad30dc5ae2 command line processing was improved 2019-08-05 03:06:40 +02:00
Frank Skare
3f74344b99 terminal screenshot 2019-08-01 20:29:43 +02:00
Frank Skare
96d8d88d09 readme update 2019-08-01 12:54:15 +02:00
28 changed files with 446 additions and 189 deletions

View File

@@ -1,3 +1,45 @@
### 5.4
- added taskbar-progress implementation
- added new setting to start with maximized window
- long file paths work now even if not enabled by the OS
- fixed history being written even when history file wasn't created prior
- libmpv updated to shinchiro 2019-08-31
### 5.3
- added new feature: Open > Open DVD/Blu-ray Drive/Folder...
- the default of remember-volume has been set to yes
- scale, cscale, dscale defaults have been set to spline36,
profile=gpu-hq is not used in the defaults because it starts very slow
- new menu items have been added to navigate to the first and
last playlist position, key bindings: Home, End
- new config setting recent-count added, amount of menu items
shown under 'Open > Recent'
- in the config dialog the description for keep-open was corrected
because unlike mpv, mpv.net will never terminate automatically
- there was a rare occasion where the mpv.net logo wasn't shown
- fix excessive memory usage using `osd-scale-by-window = no`
- mpv setting osd-scale-by-window added to config dialog
### 5.2.1
- fixed race condition causing various features to fail
### 5.2
- bug fix for single-instance not working with unicode filenames
- bug fix for logo not shown on start
- osd-visibility.js script was removed because the OSC uses too much memory
- youtube-dl was updated
- libmpv was updated to shinchiro 2019-08-04
- in case mpv.net was started from a terminal it sets now the mpv property input-terminal to yes,
this means mpv.net will now receive and handle input keys from the terminal
- certain command line properties didn't work (input-terminal, terminal, input-file,
config, config-dir, input-conf, load-scripts, script, scripts, player-operation-mode)
- the about dialog shows now the mpv version and build date
- the dialog that asks for a config folder has now a cancel option
### 5.1 ### 5.1
- 'Tools > Execute mpv command' was replaced with [mpv-repl](https://github.com/rossy/mpv-repl) - 'Tools > Execute mpv command' was replaced with [mpv-repl](https://github.com/rossy/mpv-repl)
@@ -12,7 +54,7 @@
- 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup', - 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup',
it has now a feature to add and remove mpv.net to and from the Path it has now a feature to add and remove mpv.net to and from the Path
environment variable and the OS default apps settings can be opened (Win 10 only) environment variable and the OS default apps settings can be opened (Win 10 only)
- startup folder and config folder beeing identical was causing a critical issue - startup folder and config folder being identical was causing a critical issue
as mpv.net was loading extensions twice and scripts four times, now identical as mpv.net was loading extensions twice and scripts four times, now identical
folders are no longer permitted folders are no longer permitted
- error messages are shown when unknown scripts and extensions are found in the startup folder - error messages are shown when unknown scripts and extensions are found in the startup folder

View File

@@ -149,9 +149,11 @@ The Open Files menu entry is one way to open files in mpv.net, it supports multi
Another way to open files is the command line, it is used by the Windows File Explorer if file associations exist. Another way to open files is the command line, it is used by the Windows File Explorer if file associations exist.
When mpv.net is started from a terminal such as PowerShell, mpv.net attaches to the terminal and outputs status and debug messages.
A third way is to drag and drop files on the main window. A third way is to drag and drop files on the main window.
Whenever the control key is pressed when files are opened, the playlist is not cleared but the files are appended to the playlist. Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This works in all mpv.net features that open files or URLs.
### Open > Open URL ### Open > Open URL
@@ -159,7 +161,9 @@ The Open URL menu entry can be used to open URLs for example from YouTube.
mpv.net monitors the Windows clipboard and ask if URLs should be played in case it finds a URL in the clipboard. This feature uses a keyword whitelist that can be configured in the config editor. mpv.net monitors the Windows clipboard and ask if URLs should be played in case it finds a URL in the clipboard. This feature uses a keyword whitelist that can be configured in the config editor.
Whenever the control key is pressed when URLs are opened, the playlist is not cleared but the URLs are appended to the playlist. When mpv.net is started from a terminal such as PowerShell, mpv.net attaches to the terminal and outputs status and debug messages.
Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This works in all mpv.net features that open files or URLs.
### Open > Show media search ### Open > Show media search

View File

@@ -62,7 +62,8 @@ Table of contents
- Language agnostic JSON IPC to control the player with a external programs - Language agnostic JSON IPC to control the player with a external programs
- On Screen Controler (OSC, play control buttons) - On Screen Controler (OSC, play control buttons)
- [Command Line Interface](https://mpv.io/manual/master/#options) - [Command Line Interface](https://mpv.io/manual/master/#options)
- If started from a PowerShell terminal mpv.net will attach to the terminal and print status and debug output - If started from a PowerShell terminal mpv.net will attach to the terminal and print status and debug output ([Screenshot](#terminal-and-repl-screenshot))
- [OSD REPL](https://github.com/rossy/mpv-repl)
- DXVA2 video decoding acceleration - DXVA2 video decoding acceleration
- OpenGL based video output capable of features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more - OpenGL based video output capable of features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more
- Search feature powered by [Everything](https://www.voidtools.com) to find and play media ([Screenshot](#media-search-screenshot)) - Search feature powered by [Everything](https://www.voidtools.com) to find and play media ([Screenshot](#media-search-screenshot))
@@ -79,7 +80,7 @@ Table of contents
- Screenshot feature with many options - Screenshot feature with many options
- File history feature to log time and filename - File history feature to log time and filename
- A-B loop feature - A-B loop feature
- watch later feature to save the position - Watch later feature to save the position
- [Manual](#manual) - [Manual](#manual)
### Screenshots ### Screenshots
@@ -100,6 +101,12 @@ A searchable config editor as alternative to edit the mpv.conf file manually.
![](https://raw.githubusercontent.com/stax76/mpv.net/master/img/ConfEditor.png) ![](https://raw.githubusercontent.com/stax76/mpv.net/master/img/ConfEditor.png)
#### Terminal and REPL Screenshot
mpv.net attached to a PowerShell terminal showing the [OSD REPL](https://github.com/rossy/mpv-repl).
![](https://raw.githubusercontent.com/stax76/mpv.net/master/img/Terminal.png)
#### Input Editor Screenshot #### Input Editor Screenshot
A searchable key and mouse binding editor. A searchable key and mouse binding editor.

View File

@@ -30,7 +30,7 @@ namespace RatingExtension // the assembly name must end with 'Extension'
{ {
string filepath = i.Key; string filepath = i.Key;
int rating = i.Value; int rating = i.Value;
if (String.IsNullOrEmpty(filepath) || ! File.Exists(filepath)) if (String.IsNullOrEmpty(filepath) || !File.Exists(filepath))
return; return;
string basename = Path.GetFileNameWithoutExtension(filepath); string basename = Path.GetFileNameWithoutExtension(filepath);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 628 KiB

BIN
img/Terminal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@@ -8,14 +8,14 @@ namespace mpvnet
{ {
public class App public class App
{ {
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm webm wmv y4m".Split(' '); public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' ');
public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' '); public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' ');
public static string[] ImageTypes { get; } = {"jpg", "bmp", "gif", "png"}; public static string[] ImageTypes { get; } = {"jpg", "bmp", "gif", "png"};
public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" }; public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" };
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" }; public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName; public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
public static string ConfPath { get; } = mp.ConfigFolder + "\\mpvnet.conf"; public static string ConfPath { get => mp.ConfigFolder + "mpvnet.conf"; }
public static string DarkMode { get; set; } = "always"; public static string DarkMode { get; set; } = "always";
public static string ProcessInstance { get; set; } = "single"; public static string ProcessInstance { get; set; } = "single";
public static string DarkColor { get; set; } public static string DarkColor { get; set; }
@@ -23,13 +23,15 @@ namespace mpvnet
public static bool RememberHeight { get; set; } = true; public static bool RememberHeight { get; set; } = true;
public static bool RememberPosition { get; set; } public static bool RememberPosition { get; set; }
public static bool Maximized { get; set; }
public static bool DebugMode { get; set; } public static bool DebugMode { get; set; }
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes"; public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
public static bool RememberVolume { get; set; } public static bool RememberVolume { get; set; } = true;
public static bool AutoLoadFolder { get; set; } = true; public static bool AutoLoadFolder { get; set; } = true;
public static bool ThemedMenu { get; set; } public static bool ThemedMenu { get; set; }
public static int StartThreshold { get; set; } = 1500; public static int StartThreshold { get; set; } = 1500;
public static int RecentCount { get; set; } = 15;
public static float MinimumAspectRatio { get; set; } = 1.3f; public static float MinimumAspectRatio { get; set; } = 1.3f;
@@ -49,7 +51,7 @@ namespace mpvnet
{ {
try try
{ {
string filePath = mp.ConfigFolder + "\\mpvnet-debug.log"; string filePath = mp.ConfigFolder + "mpvnet-debug.log";
if (File.Exists(filePath)) File.Delete(filePath); if (File.Exists(filePath)) File.Delete(filePath);
Trace.Listeners.Add(new TextWriterTraceListener(filePath)); Trace.Listeners.Add(new TextWriterTraceListener(filePath));
Trace.AutoFlush = true; Trace.AutoFlush = true;
@@ -105,6 +107,7 @@ namespace mpvnet
switch (name) switch (name)
{ {
case "remember-position": RememberPosition = value == "yes"; return true; case "remember-position": RememberPosition = value == "yes"; return true;
case "maximized": Maximized = value == "yes"; return true;
case "start-size": RememberHeight = value == "previous"; return true; case "start-size": RememberHeight = value == "previous"; return true;
case "process-instance": ProcessInstance = value; return true; case "process-instance": ProcessInstance = value; return true;
case "dark-mode": DarkMode = value; return true; case "dark-mode": DarkMode = value; return true;
@@ -117,6 +120,7 @@ namespace mpvnet
case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); return true; case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); return true;
case "auto-load-folder": AutoLoadFolder = value == "yes"; return true; case "auto-load-folder": AutoLoadFolder = value == "yes"; return true;
case "themed-menu": ThemedMenu = value == "yes"; return true; case "themed-menu": ThemedMenu = value == "yes"; return true;
case "recent-count": RecentCount = value.Int(); return true;
} }
return false; return false;
} }

View File

@@ -16,11 +16,14 @@ namespace mpvnet
{ {
switch (id) switch (id)
{ {
case "manage-file-associations": ManageFileAssociations(); break; // deprecated 2019 case "open-files": OpenFiles(args); break;
case "open-url": OpenURL(); break;
case "open-optical-media": Open_DVD_Or_BD_Folder(); break;
case "manage-file-associations": // deprecated 2019
case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break;
case "cycle-audio": CycleAudio(); break; case "cycle-audio": CycleAudio(); break;
case "load-audio": LoadAudio(); break; case "load-audio": LoadAudio(); break;
case "load-sub": LoadSubtitle(); break; case "load-sub": LoadSubtitle(); break;
case "open-url": OpenURL(); break;
case "execute-mpv-command": ExecuteMpvCommand(); break; case "execute-mpv-command": ExecuteMpvCommand(); break;
case "show-history": ShowHistory(); break; case "show-history": ShowHistory(); break;
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break; case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
@@ -28,11 +31,10 @@ namespace mpvnet
case "show-about": ShowDialog(typeof(AboutWindow)); break; case "show-about": ShowDialog(typeof(AboutWindow)); break;
case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break; case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break;
case "show-input-editor": ShowDialog(typeof(InputWindow)); break; case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break;
case "open-conf-folder": Process.Start(mp.ConfigFolder); break; case "open-conf-folder": Process.Start(mp.ConfigFolder); break;
case "open-files": OpenFiles(args); break;
case "shell-execute": Process.Start(args[0]); break; case "shell-execute": Process.Start(args[0]); break;
case "show-info": ShowInfo(); break; case "show-info": ShowInfo(); break;
case "playlist-last": PlaylistLast(); break;
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019 case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
default: Msg.ShowError($"No command '{id}' found."); break; default: Msg.ShowError($"No command '{id}' found."); break;
} }
@@ -67,16 +69,44 @@ namespace mpvnet
})); }));
} }
public static void Open_DVD_Or_BD_Folder()
{
InvokeOnMainThread(new Action(() => {
using (var d = new FolderBrowserDialog())
{
d.Description = "Select a DVD or Blu-ray folder.";
d.ShowNewFolderButton = false;
if (d.ShowDialog() == DialogResult.OK)
{
if (Directory.Exists(d.SelectedPath + "\\BDMV"))
{
mp.set_property_string("bluray-device", d.SelectedPath);
mp.Load(new[] { @"bd://" }, false, false);
}
else
{
mp.set_property_string("dvd-device", d.SelectedPath);
mp.Load(new[] { @"dvd://" }, false, false);
}
}
}
}));
}
public static void PlaylistLast() => mp.set_property_int("playlist-pos", mp.get_property_int("playlist-count") - 1);
public static void ShowHistory() public static void ShowHistory()
{ {
var fp = mp.ConfigFolder + "history.txt"; if (File.Exists(mp.ConfigFolder + "history.txt"))
Process.Start(mp.ConfigFolder + "history.txt");
if (File.Exists(fp))
Process.Start(fp);
else else
{
if (Msg.ShowQuestion("Create history.txt file in config folder?", if (Msg.ShowQuestion("Create history.txt file in config folder?",
"mpv.net will write the date, time and filename of opened files to it.") == MsgResult.OK) "mpv.net will write the date, time and filename of opened files to it.") == MsgResult.OK)
File.WriteAllText(fp, "");
File.WriteAllText(mp.ConfigFolder + "history.txt", "");
}
} }
public static void ShowInfo() public static void ShowInfo()
@@ -230,7 +260,5 @@ namespace mpvnet
mp.commandv("show-text", audTracks[aid - 1].Text.Substring(3), "5000"); mp.commandv("show-text", audTracks[aid - 1].Text.Substring(3), "5000");
} }
} }
public static void ManageFileAssociations() => ShowDialog(typeof(SetupWindow)); // deprecated 2019
} }
} }

View File

@@ -34,7 +34,7 @@ namespace mpvnet
} }
} }
dir = mp.ConfigFolder + "Extensions"; dir = mp.ConfigFolder + "extensions";
if (Directory.Exists(dir)) if (Directory.Exists(dir))
foreach (string i in Directory.GetDirectories(dir)) foreach (string i in Directory.GetDirectories(dir))

View File

@@ -18,6 +18,8 @@ namespace mpvnet
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
if (mp.ConfigFolder == "") return;
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
if (args.Length == 2 && args[0] == "--reg-file-assoc") if (args.Length == 2 && args[0] == "--reg-file-assoc")
@@ -38,7 +40,7 @@ namespace mpvnet
files.Add(App.ProcessInstance); files.Add(App.ProcessInstance);
foreach (string arg in args) foreach (string arg in args)
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg))) if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || arg.Contains(":\\") || arg.StartsWith("\\\\")))
files.Add(arg); files.Add(arg);
Process[] procs = Process.GetProcessesByName("mpvnet"); Process[] procs = Process.GetProcessesByName("mpvnet");

View File

@@ -27,6 +27,9 @@ namespace mpvnet
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [DllImport("user32.dll", SetLastError = true, 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)]
public static extern int RegisterWindowMessage(string id);
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool AllowSetForegroundWindow(int dwProcessId); public static extern bool AllowSetForegroundWindow(int dwProcessId);
@@ -88,7 +91,7 @@ namespace mpvnet
{ {
public IntPtr dwData; public IntPtr dwData;
public int cbData; public int cbData;
[MarshalAs(UnmanagedType.LPStr)] [MarshalAs(UnmanagedType.LPTStr)]
public string lpData; public string lpData;
} }
} }

View File

@@ -359,7 +359,7 @@ public class TaskDialog<T> : TaskDialogNative, IDisposable
public void AddCommandLink(string text, T value) public void AddCommandLink(string text, T value)
{ {
int n = 1000 + IdValueDic.Count + 1; int n = 1000 + IdValueDic.Count + 1;
IdValueDic[n] = value == null ? (T)(object)text : value; IdValueDic[n] = value;
IdTextDic[n] = text; IdTextDic[n] = text;
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text)); Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_USE_COMMAND_LINKS; Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_USE_COMMAND_LINKS;

53
mpv.net/Native/Taskbar.cs Normal file
View File

@@ -0,0 +1,53 @@
using System;
using System.Runtime.InteropServices;
public class Taskbar
{
private ITaskbarList3 Instance = (ITaskbarList3)new TaskBarCommunication();
public IntPtr Handle { get; set; }
public Taskbar(IntPtr handle) => Handle = handle;
[ComImportAttribute]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
[GuidAttribute("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")]
private interface ITaskbarList3
{
// ITaskbarList
[PreserveSig] void HrInit();
[PreserveSig] void AddTab(IntPtr hwnd);
[PreserveSig] void DeleteTab(IntPtr hwnd);
[PreserveSig] void ActivateTab(IntPtr hwnd);
[PreserveSig] void SetActiveAlt(IntPtr hwnd);
// ITaskbarList2
[PreserveSig] void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
// ITaskbarList3
[PreserveSig] void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
[PreserveSig] void SetProgressState(IntPtr hwnd, TaskbarStates state);
}
[ComImportAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
private class TaskBarCommunication { }
public void SetState(TaskbarStates taskbarState)
{
Instance.SetProgressState(Handle, taskbarState);
}
public void SetValue(double progressValue, double progressMax)
{
Instance.SetProgressValue(Handle, (UInt64)progressValue, (UInt64)progressMax);
}
}
public enum TaskbarStates
{
NoProgress = 0,
Indeterminate = 0x1,
Normal = 0x2,
Error = 0x4,
Paused = 0x8
}

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.1.0.0")] [assembly: AssemblyVersion("5.4.0.0")]
[assembly: AssemblyFileVersion("5.1.0.0")] [assembly: AssemblyFileVersion("5.4.0.0")]

View File

@@ -1,17 +1,11 @@
# This file defines the input (keys and mouse) bindings of mpv and mpv.net # This file defines the key and mouse bindings and the context menu
# and it also defines the context menu of mpv.net. mpv.net has an input # of mpv.net. A input and config editor can be found in mpv.net's
# editor and an config editor as alternative to editing conf text files. # context menu under 'Settings'. The defaults of this file can be found at:
# The input and config editor can be found in mpv.net's context menu at:
# Settings > Show Config Editor
# Settings > Show Input Editor
# The defaults of this file can be found at:
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt # https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt
# the defaults of mpv can be found at: # The defaults of mpv can be found at:
# https://github.com/mpv-player/mpv/blob/master/etc/input.conf # https://github.com/mpv-player/mpv/blob/master/etc/input.conf
@@ -26,16 +20,17 @@
# run mpv.net in input test mode with: mpvnet --input-test # run mpv.net in input test mode with: mpvnet --input-test
o script-message mpv.net open-files #menu: Open > Open Files... o script-message mpv.net open-files #menu: Open > Open Files...
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
_ ignore #menu: Open > - _ script-message mpv.net open-optical-media #menu: Open > Open DVD/Blu-ray Drive/Folder...
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files... _ ignore #menu: Open > -
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files... Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
_ ignore #menu: Open > - Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
_ script-message mpv.net open-files append #menu: Open > Add files to playlist... _ ignore #menu: Open > -
F3 script-message mpv.net show-media-search #menu: Open > Show media search... _ script-message mpv.net open-files append #menu: Open > Add files to playlist...
_ ignore #menu: Open > - F3 script-message mpv.net show-media-search #menu: Open > Show media search...
_ ignore #menu: Open > Recent _ ignore #menu: Open > -
_ ignore #menu: Open > Recent
_ ignore #menu: - _ ignore #menu: -
Space cycle pause #menu: Play/Pause Space cycle pause #menu: Play/Pause
@@ -46,6 +41,9 @@
F11 playlist-prev #menu: Navigate > Previous File F11 playlist-prev #menu: Navigate > Previous File
F12 playlist-next #menu: Navigate > Next File F12 playlist-next #menu: Navigate > Next File
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
Home set playlist-pos 0 #menu: Navigate > First File
End script-message mpv.net playlist-last #menu: Navigate > Last File
_ ignore #menu: Navigate > -
PGUP add chapter 1 #menu: Navigate > Next Chapter PGUP add chapter 1 #menu: Navigate > Next Chapter
PGDWN add chapter -1 #menu: Navigate > Previous Chapter PGDWN add chapter -1 #menu: Navigate > Previous Chapter
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
@@ -199,4 +197,3 @@
Ctrl+Wheel_Down no-osd seek -7 Ctrl+Wheel_Down no-osd seek -7
MBTN_Left_DBL cycle fullscreen MBTN_Left_DBL cycle fullscreen
KP_Enter cycle fullscreen KP_Enter cycle fullscreen
MBTN_Left ignore

View File

@@ -1,10 +1,12 @@
input-ar-delay = 500 input-default-bindings = no
input-ar-delay = 500
input-ar-rate = 20 input-ar-rate = 20
volume = 50
hwdec = yes
keep-open = yes keep-open = yes
keep-open-pause = no keep-open-pause = no
osd-playing-msg = '${filename}' osd-playing-msg = '${filename}'
screenshot-directory = '~~desktop/'
input-default-bindings = no
script-opts=osc-scalewindowed=1.5 script-opts=osc-scalewindowed=1.5
screenshot-directory = '~~desktop/'
cscale = spline36
dscale = spline36
scale = spline36
hwdec = yes

View File

@@ -23,10 +23,10 @@ options = [{ name = "no", help = "always use software decoding" },
name = "gpu-api" name = "gpu-api"
default = "auto" default = "auto"
filter = "Video" filter = "Video"
help = "Controls which type of graphics APIs will be accepted." help = "Controls which type of graphics APIs will be accepted. Auto uses d3d11, it should only be changed in case of problems, Vulkan is not recommended."
options = [{ name = "auto", help = "Use any available API" }, options = [{ name = "auto", help = "Use any available API" },
{ name = "opengl", help = "Allow only OpenGL (requires OpenGL 2.1+ or GLES 2.0+)" }, { name = "opengl", help = "Allow only OpenGL (requires OpenGL 2.1+ or GLES 2.0+)" },
{ name = "vulkan", help = "Allow only Vulkan (requires a valid/working spirv-compiler)" }, { name = "vulkan", help = "Allow only Vulkan (not recommended). " },
{ name = "d3d11", help = "Allow only gpu-context=d3d11" }] { name = "d3d11", help = "Allow only gpu-context=d3d11" }]
[[settings]] [[settings]]
@@ -241,6 +241,14 @@ default = "55"
filter = "Screen" filter = "Screen"
help = "Specify the OSD font size. See sub-font-size for details. Default: 55" help = "Specify the OSD font size. See sub-font-size for details. Default: 55"
[[settings]]
name = "osd-scale-by-window"
default = "yes"
filter = "Screen"
help = "Whether to scale the OSD with the window size. If this is disabled, osd-font-size and other OSD options that use scaled pixels are always in actual pixels. The effect is that changing the window size won't change the OSD font size."
options = [{ name = "yes" },
{ name = "no" }]
[[settings]] [[settings]]
name = "autofit" name = "autofit"
filter = "Screen" filter = "Screen"
@@ -283,7 +291,7 @@ options = [{ name = "yes" },
name = "screenshot-high-bit-depth" name = "screenshot-high-bit-depth"
default = "yes" default = "yes"
filter = "Screen" filter = "Screen"
help = "If possible, write screenshots with a bit depth similar to the source video (default: yes). This is interesting in particular for PNG, as this sometimes triggers writing 16 bit PNGs with huge file sizes. This will also include an unused alpha channel in the resulting files if 16 bit is used." help = "If possible, write screenshots with a bit depth similar to the source video. This is interesting in particular for PNG, as this sometimes triggers writing 16 bit PNGs with huge file sizes. This will also include an unused alpha channel in the resulting files if 16 bit is used."
options = [{ name = "yes" }, options = [{ name = "yes" },
{ name = "no" }] { name = "no" }]
@@ -291,7 +299,7 @@ options = [{ name = "yes" },
name = "screenshot-jpeg-source-chroma" name = "screenshot-jpeg-source-chroma"
default = "yes" default = "yes"
filter = "Screen" filter = "Screen"
help = "Write JPEG files with the same chroma subsampling as the video (default: yes). If disabled, the libjpeg default is used." help = "Write JPEG files with the same chroma subsampling as the video. If disabled, the libjpeg default is used."
options = [{ name = "yes" }, options = [{ name = "yes" },
{ name = "no" }] { name = "no" }]
@@ -317,6 +325,14 @@ name = "screenshot-png-filter"
filter = "Screen" filter = "Screen"
help = "<0-5> Set the filter applied prior to PNG compression. 0 is none, 1 is 'sub', 2 is 'up', 3 is 'average', 4 is 'Paeth', and 5 is 'mixed'. This affects the level of compression that can be achieved. For most images, 'mixed' achieves the best compression ratio, hence it is the default." help = "<0-5> Set the filter applied prior to PNG compression. 0 is none, 1 is 'sub', 2 is 'up', 3 is 'average', 4 is 'Paeth', and 5 is 'mixed'. This affects the level of compression that can be achieved. For most images, 'mixed' achieves the best compression ratio, hence it is the default."
[[settings]]
name = "taskbar-progress"
default = "yes"
filter = "Playback"
help = "Show progress in taskbar."
options = [{ name = "yes" },
{ name = "no" }]
[[settings]] [[settings]]
name = "keep-open-pause" name = "keep-open-pause"
default = "yes" default = "yes"
@@ -329,10 +345,10 @@ options = [{ name = "yes" },
name = "keep-open" name = "keep-open"
default = "no" default = "no"
filter = "Playback" filter = "Playback"
help = "Do not terminate when playing or seeking beyond the end of the file, and there is not next file to be played (and loop is not used). Instead, pause the player. When trying to seek beyond end of the file, the player will attempt to seek to the last frame.\n\nNormally, this will act like set pause yes on EOF, unless the keep-open-pause=no option is set." help = "Using no, mpv would terminate after the last file but mpv.net never terminates automatically."
options = [{ name = "yes", help = "Don't terminate if the current file is the last playlist entry. Equivalent to keep-open without arguments."}, options = [{ name = "yes", help = "If the current file ends, go to the next file, keep the last file open."},
{ name = "no", help = "If the current file ends, go to the next file or terminate." }, { name = "no", help = "If the current file ends, go to the next file." },
{ name = "always", help = "Like yes, but also applies to files before the last playlist entry. This means playback will never automatically advance to the next file."}] { name = "always", help = "Playback will never automatically advance to the next file."}]
[[settings]] [[settings]]
name = "loop-file" name = "loop-file"

View File

@@ -15,12 +15,9 @@ options = [{ name = "multi", help = "Create a new process everytime the shell s
{ name = "queue", help = "Force a single process and add files to playlist" }] { name = "queue", help = "Force a single process and add files to playlist" }]
[[settings]] [[settings]]
name = "debug-mode" name = "recent-count"
default = "no"
filter = "General" filter = "General"
help = "Enable this only when a developer asks for it. (mpv.net specific setting)" help = "<int> Amount of recent files to be remembered. Default: 15 (mpv.net specific setting)"
options = [{ name = "yes" },
{ name = "no" }]
[[settings]] [[settings]]
name = "start-size" name = "start-size"
@@ -33,12 +30,12 @@ options = [{ name = "video", help = "Window size is set to native video resoluti
[[settings]] [[settings]]
name = "start-threshold" name = "start-threshold"
filter = "Screen" filter = "Screen"
help = "Threshold in milliseconds to wait for libmpv returning the video resolution before the window is shown, otherwise default dimensions are used as defined by autofit and start-size. (mpv.net specific setting) Default: 1500" help = "Threshold in milliseconds to wait for libmpv returning the video resolution before the window is shown, otherwise default dimensions are used as defined by autofit and start-size. Default: 1500 (mpv.net specific setting)"
[[settings]] [[settings]]
name = "minimum-aspect-ratio" name = "minimum-aspect-ratio"
filter = "Screen" filter = "Screen"
help = "<float> Minimum aspect ratio for the window. Default: 1.3" help = "<float> Minimum aspect ratio for the window. Default: 1.3 (mpv.net specific setting)"
[[settings]] [[settings]]
name = "remember-position" name = "remember-position"
@@ -49,8 +46,16 @@ options = [{ name = "yes" },
{ name = "no" }] { name = "no" }]
[[settings]] [[settings]]
name = "remember-volume" name = "maximized"
default = "no" default = "no"
filter = "Screen"
help = "Start with a maximized window. (mpv.net specific setting)"
options = [{ name = "yes" },
{ name = "no" }]
[[settings]]
name = "remember-volume"
default = "yes"
filter = "Audio" filter = "Audio"
help = "Save volume and mute on exit and restore it on start. (mpv.net specific setting)" help = "Save volume and mute on exit and restore it on start. (mpv.net specific setting)"
options = [{ name = "yes" }, options = [{ name = "yes" },
@@ -92,3 +97,11 @@ filter = "UI"
help = "Follow theme color in context menu. (mpv.net specific setting)" help = "Follow theme color in context menu. (mpv.net specific setting)"
options = [{ name = "yes" }, options = [{ name = "yes" },
{ name = "no" }] { name = "no" }]
[[settings]]
name = "debug-mode"
default = "no"
filter = "General"
help = "Enable this only when a developer asks for it. (mpv.net specific setting)"
options = [{ name = "yes" },
{ name = "no" }]

View File

@@ -96,7 +96,7 @@ namespace mpvnet
public Delegate Delegate { get; set; } public Delegate Delegate { get; set; }
public string FilePath { get; set; } public string FilePath { get; set; }
public void Invoke() => Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), null); }); public void Invoke() => Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), null));
public void InvokeEndFileEventMode(EndFileEventMode arg) public void InvokeEndFileEventMode(EndFileEventMode arg)
{ {

View File

@@ -4,13 +4,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
Title="About mpv.net" Height="230" Width="420" FontSize="16" ShowInTaskbar="False" Title="About mpv.net" Height="230" Width="400" FontSize="16" ShowInTaskbar="False"
WindowStartupLocation="CenterOwner" ResizeMode="NoResize"> WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
<Grid> <Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock> <TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock>
<TextBlock HorizontalAlignment="Center">Copyright (c) 2017-2019 Frank Skare (stax76)</TextBlock> <TextBlock HorizontalAlignment="Center">Copyright (c) 2017-2019 Frank Skare (stax76)</TextBlock>
<TextBlock Name="Version" HorizontalAlignment="Center" /> <TextBlock Name="Version" HorizontalAlignment="Center" />
<TextBlock Name="mpvVersion" HorizontalAlignment="Center" />
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20">MIT License</TextBlock> <TextBlock HorizontalAlignment="Center" Margin="0,0,0,20">MIT License</TextBlock>
</StackPanel> </StackPanel>
</Grid> </Grid>

View File

@@ -1,6 +1,6 @@
using System.Windows; using System.IO;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
namespace mpvnet namespace mpvnet
{ {
@@ -9,7 +9,8 @@ namespace mpvnet
public AboutWindow() public AboutWindow()
{ {
InitializeComponent(); InitializeComponent();
Version.Text = $"Version {System.Windows.Forms.Application.ProductVersion}"; 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()})";
} }
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close(); protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();

View File

@@ -193,6 +193,7 @@ namespace mpvnet
{ {
SearchControl.SearchTextBox.SelectAll(); SearchControl.SearchTextBox.SelectAll();
Keyboard.Focus(SearchControl.SearchTextBox); Keyboard.Focus(SearchControl.SearchTextBox);
foreach (var i in MainStackPanel.Children.OfType<StringSettingControl>()) foreach (var i in MainStackPanel.Children.OfType<StringSettingControl>())
i.Update(); i.Update();
} }

View File

@@ -30,14 +30,19 @@
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.Timer = new System.Windows.Forms.Timer(this.components); this.CursorTimer = new System.Windows.Forms.Timer(this.components);
this.ProgressTimer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout(); this.SuspendLayout();
// //
// Timer // CursorTimer
// //
this.Timer.Enabled = true; this.CursorTimer.Enabled = true;
this.Timer.Interval = 1000; this.CursorTimer.Interval = 1000;
this.Timer.Tick += new System.EventHandler(this.Timer_Tick); this.CursorTimer.Tick += new System.EventHandler(this.CursorTimer_Tick);
//
// ProgressTimer
//
this.ProgressTimer.Tick += new System.EventHandler(this.ProgressTimer_Tick);
// //
// MainForm // MainForm
// //
@@ -45,7 +50,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F); this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.Black; this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(542, 0); this.ClientSize = new System.Drawing.Size(348, 0);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
@@ -57,6 +62,7 @@
#endregion #endregion
private System.Windows.Forms.Timer Timer; private System.Windows.Forms.Timer CursorTimer;
private System.Windows.Forms.Timer ProgressTimer;
} }
} }

View File

@@ -16,12 +16,12 @@ namespace mpvnet
{ {
public static MainForm Instance { get; set; } public static MainForm Instance { get; set; }
public static IntPtr Hwnd { get; set; } public static IntPtr Hwnd { get; set; }
public new ContextMenuStripEx ContextMenu { get; set; } public new ContextMenuStripEx ContextMenu { get; set; }
Point LastCursorPosChanged; Point LastCursorPosChanged;
int LastCursorChangedTickCount; int LastCursorChangedTickCount;
int TaskbarButtonCreatedMessage;
bool WasShown; bool WasShown;
Taskbar Taskbar;
List<string> RecentFiles; List<string> RecentFiles;
public MainForm() public MainForm()
@@ -33,10 +33,29 @@ namespace mpvnet
Instance = this; Instance = this;
Hwnd = Handle; Hwnd = Handle;
mp.Init(); mp.Init();
mp.Shutdown += Shutdown;
mp.VideoSizeChanged += VideoSizeChanged;
mp.FileLoaded += FileLoaded;
mp.Idle += Idle;
mp.Seek += () => UpdateProgressBar();
mp.observe_property_bool("pause", PropChangePause);
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
mp.observe_property_bool("ontop", PropChangeOnTop);
mp.observe_property_bool("border", PropChangeBorder);
mp.observe_property_string("sid", PropChangeSid);
mp.observe_property_string("aid", PropChangeAid);
mp.observe_property_string("vid", PropChangeVid);
mp.observe_property_int("edition", PropChangeEdition);
if (mp.GPUAPI != "vulkan") mp.ProcessCommandLine(false);
AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString()); AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString());
Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception); Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception);
Msg.SupportURL = "https://github.com/stax76/mpv.net#support"; Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
Text = "mpv.net " + Application.ProductVersion; Text = "mpv.net " + Application.ProductVersion;
TaskbarButtonCreatedMessage = Native.RegisterWindowMessage("TaskbarButtonCreated");
object recent = RegHelp.GetObject(App.RegPath, "Recent"); object recent = RegHelp.GetObject(App.RegPath, "Recent");
@@ -68,21 +87,7 @@ namespace mpvnet
Top = posY - Height / 2; Top = posY - Height / 2;
} }
mp.Shutdown += Shutdown; if (App.Maximized) WindowState = FormWindowState.Maximized;
mp.VideoSizeChanged += VideoSizeChanged;
mp.FileLoaded += FileLoaded;
mp.Idle += Idle;
mp.observe_property_bool("fullscreen", PropChangeFullscreen);
mp.observe_property_bool("ontop", PropChangeOnTop);
mp.observe_property_bool("border", PropChangeBorder);
mp.observe_property_string("sid", PropChangeSid);
mp.observe_property_string("aid", PropChangeAid);
mp.observe_property_string("vid", PropChangeVid);
mp.observe_property_int("edition", PropChangeEdition);
if (mp.GPUAPI != "vulkan") mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
if (Height < FontHeight * 4) SetFormPosAndSize();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -92,19 +97,22 @@ namespace mpvnet
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items); public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
void Idle() => BeginInvoke(new Action(() => Text = "mpv.net " + Application.ProductVersion)); void Shutdown() => BeginInvoke(new Action(() => Close()));
void Idle()
{
BeginInvoke(new Action(() => Text = "mpv.net " + Application.ProductVersion));
}
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show(); void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize())); void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize()));
void Shutdown() => BeginInvoke(new Action(() => Close()));
void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value))); void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value)));
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show(); void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
bool IsFullscreen => WindowState == FormWindowState.Maximized; bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None;
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9; bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
@@ -126,7 +134,7 @@ namespace mpvnet
foreach (MediaTrack track in vidTracks) foreach (MediaTrack track in vidTracks)
{ {
MenuItem mi = new MenuItem(track.Text); MenuItem mi = new MenuItem(track.Text);
mi.Action = () => { mp.commandv("set", "vid", track.ID.ToString()); }; mi.Action = () => mp.commandv("set", "vid", track.ID.ToString());
mi.Checked = mp.Vid == track.ID.ToString(); mi.Checked = mp.Vid == track.ID.ToString();
trackMenuItem.DropDownItems.Add(mi); trackMenuItem.DropDownItems.Add(mi);
} }
@@ -137,7 +145,7 @@ namespace mpvnet
foreach (MediaTrack track in audTracks) foreach (MediaTrack track in audTracks)
{ {
MenuItem mi = new MenuItem(track.Text); MenuItem mi = new MenuItem(track.Text);
mi.Action = () => { mp.commandv("set", "aid", track.ID.ToString()); }; mi.Action = () => mp.commandv("set", "aid", track.ID.ToString());
mi.Checked = mp.Aid == track.ID.ToString(); mi.Checked = mp.Aid == track.ID.ToString();
trackMenuItem.DropDownItems.Add(mi); trackMenuItem.DropDownItems.Add(mi);
} }
@@ -148,7 +156,7 @@ namespace mpvnet
foreach (MediaTrack track in subTracks) foreach (MediaTrack track in subTracks)
{ {
MenuItem mi = new MenuItem(track.Text); MenuItem mi = new MenuItem(track.Text);
mi.Action = () => { mp.commandv("set", "sid", track.ID.ToString()); }; mi.Action = () => mp.commandv("set", "sid", track.ID.ToString());
mi.Checked = mp.Sid == track.ID.ToString(); mi.Checked = mp.Sid == track.ID.ToString();
trackMenuItem.DropDownItems.Add(mi); trackMenuItem.DropDownItems.Add(mi);
} }
@@ -156,7 +164,7 @@ namespace mpvnet
if (subTracks.Length > 0) if (subTracks.Length > 0)
{ {
MenuItem mi = new MenuItem("S: No subtitles"); MenuItem mi = new MenuItem("S: No subtitles");
mi.Action = () => { mp.commandv("set", "sid", "no"); }; mi.Action = () => mp.commandv("set", "sid", "no");
mi.Checked = mp.Sid == "no"; mi.Checked = mp.Sid == "no";
trackMenuItem.DropDownItems.Add(mi); trackMenuItem.DropDownItems.Add(mi);
} }
@@ -167,7 +175,7 @@ namespace mpvnet
foreach (MediaTrack track in ediTracks) foreach (MediaTrack track in ediTracks)
{ {
MenuItem mi = new MenuItem(track.Text); MenuItem mi = new MenuItem(track.Text);
mi.Action = () => { mp.commandv("set", "edition", track.ID.ToString()); }; mi.Action = () => mp.commandv("set", "edition", track.ID.ToString());
mi.Checked = mp.Edition == track.ID; mi.Checked = mp.Edition == track.ID;
trackMenuItem.DropDownItems.Add(mi); trackMenuItem.DropDownItems.Add(mi);
} }
@@ -186,7 +194,7 @@ namespace mpvnet
{ {
MenuItem mi = new MenuItem(i.Key); MenuItem mi = new MenuItem(i.Key);
mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(i.Value).ToString().Substring(0, 8) + " "; mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(i.Value).ToString().Substring(0, 8) + " ";
mi.Action = () => { mp.commandv("seek", i.Value.ToString(CultureInfo.InvariantCulture), "absolute"); }; mi.Action = () => mp.commandv("seek", i.Value.ToString(CultureInfo.InvariantCulture), "absolute");
chaptersMenuItem.DropDownItems.Add(mi); chaptersMenuItem.DropDownItems.Add(mi);
} }
} }
@@ -228,6 +236,9 @@ namespace mpvnet
void SetFormPosAndSize() void SetFormPosAndSize()
{ {
if (WindowState == FormWindowState.Maximized)
return;
if (mp.Fullscreen) if (mp.Fullscreen)
{ {
CycleFullscreen(true); CycleFullscreen(true);
@@ -320,7 +331,7 @@ namespace mpvnet
} }
else else
{ {
if (WindowState == FormWindowState.Maximized) if (WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None)
{ {
WindowState = FormWindowState.Normal; WindowState = FormWindowState.Normal;
@@ -367,15 +378,24 @@ namespace mpvnet
private void FileLoaded() private void FileLoaded()
{ {
string path = mp.get_property_string("path"); string path = mp.get_property_string("path");
BeginInvoke(new Action(() => { BeginInvoke(new Action(() => {
if (File.Exists(path) || path.Contains("://")) if (path.Contains("://"))
Text = path + " - mpv.net " + Application.ProductVersion;
else if (path.Contains(":\\") || path.StartsWith("\\\\"))
Text = path.FileName() + " - mpv.net " + Application.ProductVersion; Text = path.FileName() + " - mpv.net " + Application.ProductVersion;
else else
Text = "mpv.net " + Application.ProductVersion; Text = "mpv.net " + Application.ProductVersion;
ProgressTimer.Interval = (int)(mp.Duration.TotalMilliseconds / 99);
if (ProgressTimer.Interval < 100) ProgressTimer.Interval = 100;
if (ProgressTimer.Interval > 999) ProgressTimer.Interval = 999;
UpdateProgressBar();
})); }));
if (RecentFiles.Contains(path)) RecentFiles.Remove(path); if (RecentFiles.Contains(path)) RecentFiles.Remove(path);
RecentFiles.Insert(0, path); RecentFiles.Insert(0, path);
if (RecentFiles.Count > 15) RecentFiles.RemoveAt(15); while (RecentFiles.Count > App.RecentCount) RecentFiles.RemoveAt(App.RecentCount);
} }
protected override CreateParams CreateParams { protected override CreateParams CreateParams {
@@ -466,10 +486,16 @@ namespace mpvnet
return; return;
} }
if (m.Msg == TaskbarButtonCreatedMessage)
{
Taskbar = new Taskbar(Handle);
ProgressTimer.Start();
}
base.WndProc(ref m); base.WndProc(ref m);
} }
void Timer_Tick(object sender, EventArgs e) void CursorTimer_Tick(object sender, EventArgs e)
{ {
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
{ {
@@ -483,6 +509,14 @@ namespace mpvnet
CursorHelp.Hide(); CursorHelp.Hide();
} }
private void ProgressTimer_Tick(object sender, EventArgs e) => UpdateProgressBar();
void UpdateProgressBar()
{
if (mp.TaskbarProgress && Taskbar != null)
Taskbar.SetValue(mp.get_property_number("time-pos"), mp.Duration.TotalSeconds);
}
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value)); void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
void PropChangeAid(string value) => mp.Aid = value; void PropChangeAid(string value) => mp.Aid = value;
@@ -507,10 +541,28 @@ namespace mpvnet
})); }));
} }
void PropChangePause(bool enabled)
{
if (Taskbar != null)
{
if (enabled)
Taskbar.SetState(TaskbarStates.Paused);
else
Taskbar.SetState(TaskbarStates.Normal);
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (mp.GPUAPI != "vulkan") mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
SetFormPosAndSize();
}
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
{ {
base.OnShown(e); base.OnShown(e);
if (mp.GPUAPI == "vulkan") mp.ProcessCommandLine(); if (mp.GPUAPI == "vulkan") mp.ProcessCommandLine(false);
var wpfColor = WPF.WPF.ThemeColor; var wpfColor = WPF.WPF.ThemeColor;
Color color = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B); Color color = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B);
ToolStripRendererEx.InitColors(color, App.IsDarkMode, App.ThemedMenu); ToolStripRendererEx.InitColors(color, App.IsDarkMode, App.ThemedMenu);
@@ -521,8 +573,8 @@ namespace mpvnet
CheckClipboardForURL(); CheckClipboardForURL();
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y); Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
WasShown = true; WasShown = true;
Task.Run(() => { mp.LoadScripts(); }); Task.Run(() => mp.LoadScripts());
Task.Run(() => { mp.Extension = new Extension(); }); Task.Run(() => mp.Extension = new Extension());
} }
protected override void OnActivated(EventArgs e) protected override void OnActivated(EventArgs e)
@@ -603,8 +655,8 @@ namespace mpvnet
foreach (string url in App.UrlWhitelist) foreach (string url in App.UrlWhitelist)
{ {
if (clipboard.Contains("://") && ! clipboard.Contains("\n") && if (clipboard.Contains("://") && !clipboard.Contains("\n") &&
! clipboard.Contains(" ") && clipboard.Contains(url.ToLower().Trim()) && !clipboard.Contains(" ") && clipboard.Contains(url.ToLower().Trim()) &&
RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible) RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
{ {
RegHelp.SetObject(App.RegPath, "LastURL", clipboard); RegHelp.SetObject(App.RegPath, "LastURL", clipboard);

View File

@@ -117,9 +117,12 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="CursorTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>30, 12</value> <value>30, 12</value>
</metadata> </metadata>
<metadata name="ProgressTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>321, 12</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

View File

@@ -153,6 +153,7 @@
<Compile Include="DynamicGUI\Tommy.cs" /> <Compile Include="DynamicGUI\Tommy.cs" />
<Compile Include="Misc\ExtensionMethods.cs" /> <Compile Include="Misc\ExtensionMethods.cs" />
<Compile Include="Native\MediaInfo.cs" /> <Compile Include="Native\MediaInfo.cs" />
<Compile Include="Native\Taskbar.cs" />
<Compile Include="WinForms\Menu.cs"> <Compile Include="WinForms\Menu.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>

View File

@@ -61,17 +61,17 @@ namespace mpvnet
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>(); public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>(); public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>(); public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
public static IntPtr Handle { get; set; } public static IntPtr Handle { get; set; }
public static IntPtr WindowHandle { get; set; } public static IntPtr WindowHandle { get; set; }
public static Extension Extension { get; set; } public static Extension Extension { get; set; }
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>(); public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
public static Size VideoSize { get; set; } public static Size VideoSize { get; set; }
public static TimeSpan Duration;
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false); public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false); public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static string InputConfPath { get; } = ConfigFolder + "\\input.conf"; public static string InputConfPath { get => ConfigFolder + "input.conf"; }
public static string ConfPath { get; } = ConfigFolder + "\\mpv.conf"; public static string ConfPath { get => ConfigFolder + "mpv.conf"; }
public static string Sid { get; set; } = ""; public static string Sid { get; set; } = "";
public static string Aid { get; set; } = ""; public static string Aid { get; set; } = "";
public static string Vid { get; set; } = ""; public static string Vid { get; set; } = "";
@@ -81,6 +81,7 @@ namespace mpvnet
public static bool IsQuitNeeded { set; get; } = true; public static bool IsQuitNeeded { set; get; } = true;
public static bool Fullscreen { get; set; } public static bool Fullscreen { get; set; }
public static bool Border { get; set; } = true; public static bool Border { get; set; } = true;
public static bool TaskbarProgress { get; set; } = true;
public static int Screen { get; set; } = -1; public static int Screen { get; set; } = -1;
public static int Edition { get; set; } public static int Edition { get; set; }
@@ -93,26 +94,26 @@ namespace mpvnet
{ {
LoadLibrary("mpv-1.dll"); LoadLibrary("mpv-1.dll");
Handle = mpv_create(); Handle = mpv_create();
Task.Run(() => { EventLoop(); }); Task.Run(() => EventLoop());
if (App.IsStartedFromTerminal) if (App.IsStartedFromTerminal)
{ {
set_property_string("terminal", "yes"); set_property_string("terminal", "yes");
set_property_string("input-terminal", "yes");
set_property_string("msg-level", "osd/libass=fatal"); set_property_string("msg-level", "osd/libass=fatal");
} }
set_property_string("wid", MainForm.Hwnd.ToString()); set_property_string("wid", MainForm.Hwnd.ToString());
set_property_string("osc", "yes"); set_property_string("osc", "yes");
set_property_string("force-window", "yes");
set_property_string("input-media-keys", "yes"); set_property_string("input-media-keys", "yes");
set_property_string("force-window", "yes");
set_property_string("config-dir", ConfigFolder); set_property_string("config-dir", ConfigFolder);
set_property_string("config", "yes"); set_property_string("config", "yes");
ProcessCommandLine(true);
mpv_initialize(Handle); mpv_initialize(Handle);
Initialized?.Invoke(); Initialized?.Invoke();
ShowLogo();
LoadMpvScripts(); LoadMpvScripts();
if (GPUAPI != "vulkan") ProcessCommandLine();
} }
public static void ProcessProperty(string name, string value) public static void ProcessProperty(string name, string value)
@@ -136,6 +137,7 @@ namespace mpvnet
case "fs": case "fs":
case "fullscreen": Fullscreen = value == "yes"; break; case "fullscreen": Fullscreen = value == "yes"; break;
case "border": Border = value == "yes"; break; case "border": Border = value == "yes"; break;
case "taskbar-progress": TaskbarProgress = value == "yes"; break;
case "screen": Screen = Convert.ToInt32(value); break; case "screen": Screen = Convert.ToInt32(value); break;
case "gpu-api": GPUAPI = value; break; case "gpu-api": GPUAPI = value; break;
} }
@@ -165,10 +167,15 @@ namespace mpvnet
td.AddCommandLink(@"AppData\Roaming\mpv", appdataFolderMpv, appdataFolderMpv); td.AddCommandLink(@"AppData\Roaming\mpv", appdataFolderMpv, appdataFolderMpv);
td.AddCommandLink("<startup>\\portable_config", portableFolder, portableFolder); td.AddCommandLink("<startup>\\portable_config", portableFolder, portableFolder);
td.AddCommandLink("Choose custom folder", "custom"); td.AddCommandLink("Choose custom folder", "custom");
td.AllowCancel = false;
_ConfigFolder = td.Show(); _ConfigFolder = td.Show();
} }
if (_ConfigFolder == null)
{
_ConfigFolder = "";
return "";
}
if (_ConfigFolder == "custom") if (_ConfigFolder == "custom")
{ {
using (var d = new WinForms.FolderBrowserDialog()) using (var d = new WinForms.FolderBrowserDialog())
@@ -195,14 +202,14 @@ namespace mpvnet
if (!_ConfigFolder.Contains("portable_config")) if (!_ConfigFolder.Contains("portable_config"))
RegHelp.SetObject(App.RegPath, "ConfigFolder", _ConfigFolder); RegHelp.SetObject(App.RegPath, "ConfigFolder", _ConfigFolder);
if (!File.Exists(_ConfigFolder + "\\input.conf")) if (!File.Exists(_ConfigFolder + "input.conf"))
File.WriteAllText(_ConfigFolder + "\\input.conf", Properties.Resources.inputConf); File.WriteAllText(_ConfigFolder + "input.conf", Properties.Resources.inputConf);
if (!File.Exists(_ConfigFolder + "\\mpv.conf")) if (!File.Exists(_ConfigFolder + "mpv.conf"))
File.WriteAllText(_ConfigFolder + "\\mpv.conf", Properties.Resources.mpvConf); File.WriteAllText(_ConfigFolder + "mpv.conf", Properties.Resources.mpvConf);
if (!File.Exists(_ConfigFolder + "\\mpvnet.conf")) if (!File.Exists(_ConfigFolder + "mpvnet.conf"))
File.WriteAllText(_ConfigFolder + "\\mpvnet.conf", Properties.Resources.mpvNetConf); File.WriteAllText(_ConfigFolder + "mpvnet.conf", Properties.Resources.mpvNetConf);
} }
return _ConfigFolder; return _ConfigFolder;
} }
@@ -260,8 +267,8 @@ namespace mpvnet
} }
} }
if (Directory.Exists(ConfigFolder + "Scripts")) if (Directory.Exists(ConfigFolder + "scripts"))
foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "Scripts")) foreach (string scriptPath in Directory.GetFiles(ConfigFolder + "scripts"))
if (scriptPath.EndsWith(".py")) if (scriptPath.EndsWith(".py"))
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
else if (scriptPath.EndsWith(".ps1")) else if (scriptPath.EndsWith(".ps1"))
@@ -312,7 +319,7 @@ namespace mpvnet
break; break;
case mpv_event_id.MPV_EVENT_FILE_LOADED: case mpv_event_id.MPV_EVENT_FILE_LOADED:
HideLogo(); HideLogo();
FileLoaded?.Invoke(); Duration = TimeSpan.FromSeconds(get_property_number("duration"));
Size vidSize = new Size(get_property_int("width"), get_property_int("height")); Size vidSize = new Size(get_property_int("width"), get_property_int("height"));
if (vidSize.Width == 0 || vidSize.Height == 0) if (vidSize.Width == 0 || vidSize.Height == 0)
vidSize = new Size(1, 1); vidSize = new Size(1, 1);
@@ -324,6 +331,7 @@ namespace mpvnet
VideoSizeAutoResetEvent.Set(); VideoSizeAutoResetEvent.Set();
Task.Run(new Action(() => ReadMetaData())); Task.Run(new Action(() => ReadMetaData()));
WriteHistory(get_property_string("path")); WriteHistory(get_property_string("path"));
FileLoaded?.Invoke();
break; break;
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED: case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
TracksChanged?.Invoke(); TracksChanged?.Invoke();
@@ -333,7 +341,7 @@ namespace mpvnet
break; break;
case mpv_event_id.MPV_EVENT_IDLE: case mpv_event_id.MPV_EVENT_IDLE:
Idle?.Invoke(); Idle?.Invoke();
if (get_property_int("playlist-count") == 0) ShowLogo(); ShowLogo();
break; break;
case mpv_event_id.MPV_EVENT_PAUSE: case mpv_event_id.MPV_EVENT_PAUSE:
Pause?.Invoke(); Pause?.Invoke();
@@ -371,19 +379,22 @@ namespace mpvnet
var propData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property)); var propData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property));
if (propData.format == mpv_format.MPV_FORMAT_FLAG) if (propData.format == mpv_format.MPV_FORMAT_FLAG)
foreach (var i in BoolPropChangeActions) lock (BoolPropChangeActions)
if (i.Key== propData.name) foreach (var i in BoolPropChangeActions)
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data) == 1); if (i.Key== propData.name)
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data) == 1);
if (propData.format == mpv_format.MPV_FORMAT_STRING) if (propData.format == mpv_format.MPV_FORMAT_STRING)
foreach (var i in StringPropChangeActions) lock (StringPropChangeActions)
if (i.Key == propData.name) foreach (var i in StringPropChangeActions)
i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure<IntPtr>(propData.data))); if (i.Key == propData.name)
i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure<IntPtr>(propData.data)));
if (propData.format == mpv_format.MPV_FORMAT_INT64) if (propData.format == mpv_format.MPV_FORMAT_INT64)
foreach (var i in IntPropChangeActions) lock (IntPropChangeActions)
if (i.Key == propData.name) foreach (var i in IntPropChangeActions)
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data)); if (i.Key == propData.name)
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data));
break; break;
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
PlaybackRestart?.Invoke(); PlaybackRestart?.Invoke();
@@ -408,11 +419,8 @@ namespace mpvnet
static void HideLogo() static void HideLogo()
{ {
if (IsLogoVisible) command("overlay-remove 0");
{ IsLogoVisible = false;
commandv("overlay-remove", "0");
IsLogoVisible = false;
}
} }
static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>(); static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
@@ -542,7 +550,8 @@ namespace mpvnet
if (err < 0) if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}"); throw new Exception($"{name}: {(mpv_error)err}");
else else
IntPropChangeActions.Add(new KeyValuePair<string, Action<int>>(name, action)); lock (IntPropChangeActions)
IntPropChangeActions.Add(new KeyValuePair<string, Action<int>>(name, action));
} }
public static void observe_property_bool(string name, Action<bool> action) public static void observe_property_bool(string name, Action<bool> action)
@@ -552,7 +561,8 @@ namespace mpvnet
if (err < 0) if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}"); throw new Exception($"{name}: {(mpv_error)err}");
else else
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action)); lock (BoolPropChangeActions)
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action));
} }
public static void observe_property_string(string name, Action<string> action) public static void observe_property_string(string name, Action<string> action)
@@ -562,43 +572,44 @@ namespace mpvnet
if (err < 0) if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}"); throw new Exception($"{name}: {(mpv_error)err}");
else else
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action)); lock (StringPropChangeActions)
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
} }
public static void ProcessCommandLine() public static void ProcessCommandLine(bool preInit)
{ {
var args = Environment.GetCommandLineArgs().Skip(1); var args = Environment.GetCommandLineArgs().Skip(1);
List<string> files = new List<string>();
//Msg.Show(string.Join("\n", args));
string[] preInitProperties = { "input-terminal", "terminal", "input-file", "config", "config-dir", "input-conf", "load-scripts", "scripts", "player-operation-mode" };
foreach (string i in args) foreach (string i in args)
{ {
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i))) string arg = i;
{
files.Add(i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}
foreach (string i in args) if (arg.StartsWith("--"))
{
if (i.StartsWith("--"))
{ {
try try
{ {
if (i.Contains("=")) if (!arg.Contains("=")) arg += "=yes";
string left = arg.Substring(2, arg.IndexOf("=") - 2);
string right = arg.Substring(left.Length + 3);
if (left == "script") left = "scripts";
if (preInit && preInitProperties.Contains(left))
{ {
string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3);
mp.ProcessProperty(left, right); mp.ProcessProperty(left, right);
if (!App.ProcessProperty(left, right)) if (!App.ProcessProperty(left, right))
set_property_string(left, right, true); set_property_string(left, right, true);
} }
else else if (!preInit && !preInitProperties.Contains(left))
{ {
string name = i.Substring(2); mp.ProcessProperty(left, right);
mp.ProcessProperty(name, "yes"); if (!App.ProcessProperty(left, right))
if (!App.ProcessProperty(name, "yes")) set_property_string(left, right, true);
set_property_string(name, "yes", true);
} }
} }
catch (Exception e) catch (Exception e)
@@ -608,12 +619,27 @@ namespace mpvnet
} }
} }
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control)); if (!preInit)
if (files.Count == 0 || files[0].Contains("://"))
{ {
VideoSizeAutoResetEvent.Set(); List<string> files = new List<string>();
VideoSizeChanged?.Invoke();
foreach (string i in args)
{
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") ||
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
{
files.Add(i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
if (files.Count == 0 || files[0].Contains("://"))
{
VideoSizeChanged?.Invoke();
VideoSizeAutoResetEvent.Set();
}
} }
} }
@@ -651,7 +677,7 @@ namespace mpvnet
string path = get_property_string("path"); string path = get_property_string("path");
if (!File.Exists(path) || get_property_int("playlist-count") != 1) return; if (!File.Exists(path) || get_property_int("playlist-count") != 1) return;
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList(); List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
files = files.Where((file) => files = files.Where(file =>
App.VideoTypes.Contains(file.ShortExt()) || App.VideoTypes.Contains(file.ShortExt()) ||
App.AudioTypes.Contains(file.ShortExt()) || App.AudioTypes.Contains(file.ShortExt()) ||
App.ImageTypes.Contains(file.ShortExt())).ToList(); App.ImageTypes.Contains(file.ShortExt())).ToList();
@@ -709,17 +735,12 @@ namespace mpvnet
static void WriteHistory(string path) static void WriteHistory(string path)
{ {
if (!File.Exists(path)) return; if (!File.Exists(ConfigFolder + "history.txt") || !File.Exists(path)) return;
int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes); int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes);
if (File.Exists(LastHistoryPath) && totalMinutes > 1) if (File.Exists(LastHistoryPath) && totalMinutes > 1)
{ File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) +
string historyFilepath = ConfigFolder + "history.txt"; " " + totalMinutes.ToString().PadLeft(3) + " " + Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n");
File.AppendAllText(historyFilepath, DateTime.Now.ToString().Substring(0, 16) +
" " + totalMinutes.ToString().PadLeft(3) + " " +
Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n");
}
LastHistoryPath = path; LastHistoryPath = path;
LastHistoryStartDateTime = DateTime.Now; LastHistoryStartDateTime = DateTime.Now;