Compare commits

...

37 Commits
4.2 ... 4.6

Author SHA1 Message Date
Frank Skare
7575a2d736 - 2019-07-06 23:51:28 +02:00
Frank Skare
17c198e711 - 2019-07-06 23:46:14 +02:00
Frank Skare
1f8635e9c4 - 2019-07-06 09:35:14 +02:00
Frank Skare
37e6c198a1 - 2019-07-06 03:46:36 +02:00
Frank Skare
751c8779f4 - 2019-07-06 02:39:25 +02:00
Frank Skare
9e2bf46636 - 2019-07-05 07:17:58 +02:00
Frank Skare
3529323d93 - 2019-07-05 06:36:15 +02:00
Frank Skare
ba52c1f8b5 - 2019-07-05 05:40:14 +02:00
Frank Skare
bf2070d758 - 2019-07-05 05:38:52 +02:00
Frank Skare
7a1de4cf0f - 2019-07-05 05:05:37 +02:00
Frank Skare
caf0bee161 - 2019-07-01 04:17:16 +02:00
Frank Skare
cedd694e8e - 2019-07-01 02:45:22 +02:00
Frank Skare
d1c58585f5 - 2019-06-30 07:16:28 +02:00
Frank Skare
0fce626c46 - 2019-06-30 07:14:13 +02:00
Frank Skare
adb8f38c0d - 2019-06-30 02:09:30 +02:00
Frank Skare
735ee42580 - 2019-06-30 02:07:16 +02:00
Frank Skare
103ae81b8b - 2019-06-29 12:36:35 +02:00
Frank Skare
8e351193e1 - 2019-06-27 10:35:37 +02:00
Frank Skare
d57b9281a1 - 2019-06-27 07:51:19 +02:00
Frank Skare
e07627377e - 2019-06-27 07:44:23 +02:00
Frank Skare
8899f4b772 - 2019-06-27 06:59:34 +02:00
Frank Skare
e7fd268927 - 2019-06-27 02:43:17 +02:00
Frank Skare
c8fe3a4c43 - 2019-06-26 16:06:41 +02:00
Frank Skare
19c2502c31 - 2019-06-26 03:23:40 +02:00
Frank Skare
56dae4babd - 2019-06-26 03:16:40 +02:00
Frank Skare
bc20d7527c - 2019-06-26 02:54:59 +02:00
Frank Skare
3d325d4fe5 - 2019-06-25 05:14:58 +02:00
Frank Skare
ba0141cfb1 - 2019-06-24 09:04:18 +02:00
Frank Skare
d32c7b4056 - 2019-06-24 09:00:01 +02:00
Frank Skare
63f064ba1c - 2019-06-24 07:52:30 +02:00
Frank Skare
e5c9df31e4 - 2019-06-22 06:27:22 +02:00
Frank Skare
c0a8e895f7 - 2019-06-19 18:22:40 +02:00
Frank Skare
064ae44ecf - 2019-06-19 18:03:14 +02:00
Frank Skare
005ba6e5ea - 2019-06-18 16:20:02 +02:00
Frank Skare
9f6aba6cbd - 2019-06-18 16:08:28 +02:00
Frank Skare
87e3d9ca3e - 2019-06-17 21:35:14 +02:00
Frank Skare
29a0eae3d5 - 2019-06-16 12:46:04 +02:00
28 changed files with 724 additions and 715 deletions

View File

@@ -1,9 +1,67 @@
### 4.2 Letting Go
### 4.6
- fix for middle mouse button not working
- fix of logo overlay using a huge amount of memory (thx for the [ghacks article](https://www.ghacks.net/2019/07/05/a-look-at-mpv-net-a-mpv-frontend-with-everything-integration/))
- fix config dialog showing a message about app restart without reason
- when multiple files are selected in Windows File Explorer and enter is
pressed, the files are opened as selected, the order is random though
because Explorer starts multiple mpv.net processes concurrently
- libmpv was updated to shinchiro 2019-06-30
- the [mpv.conf defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt) were changed to show a larger OSC
- in case a file is opened that has a aspect ratio smaller then 1.2 then
the window size will use a aspect ratio of 1.8
- new JavaScript script osc-visibility.js included in the distribution
under startup\scripts. It sets the OSC to be always on for audio files
and auto for non audio files
### 4.5
- opening a URL manually no longer uses a input box but uses the clipboard directly
- the manifest was missing the company attribute which caused
mpv.net not appearing in the 'Open with' menu of the Windows File Explorer,
thanks to 44vince44 for pointing this out!!!
- new Python and C# script examples were added to the wiki and the scripting and
add-on documentation was improved
- invalid command line arguments were ignored, now an error message is shown
- a description on how to start mpv.net from Google Chrome was added to the
manual, it's useful to play videos from sites like YouTube, find the
description [here](https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension)
- new config setting remember-height added to remember the window height,
otherwise the video's native resolution is used
- support for protocols other then http added
### 4.4
- clipboard-monitoring was replaced by url-whitelist:
Keyword whitelist to monitor the clipboard for URLs to play.
Default: tube vimeo ard zdf
- some settings like colors didn't work because enclosing quotes were missing
- when single process queue is used the folder is no longer loaded
- the playlist is never cleared whenever the control key is down but
files and URLs are appended instead
- powershell script hosting bugs were fixed and a new powershell example script
was added to the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting#powershell)
- the menu entry for the command palette was renamed to 'Show All Commands' and
the default key binding was changed to F1 which is also the default in VS Code
- the default key binding of the Everything media search was changed to F3
- support for the mpv property 'border' was added to the config editor
to show/hide the window decoration (titlebar, border). A toggle menu item and
key binding (b) was added as well ([Default Binding](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L135))
### 4.3.1
- there was a old bug setting the screen property
### 4.3
- there was new bug in file association feature
### 4.2
- the help and layout in the config editor was improved
- clipboard monitoring for URLs can be disabled in the settings
- the context menu has a new feature: Open > Add files to playlist,
it appends files to the playlist [(Default binding)](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L34)
it appends files to the playlist [(Default binding)](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt#L33)
- a setting was added to force using a single mpv.net process instance
### 4.1

View File

@@ -7,6 +7,7 @@
* [Requirements](#requirements)
* [Installation](#installation)
+ [File Associations](#file-associations)
+ [Chrome Extension](#chrome-extension)
* [Context Menu](#context-menu)
+ [Open > Open Files](#open--open-files)
+ [Open > Open URL](#open--open-url)
@@ -93,9 +94,9 @@
## About mpv.net
mpv.net is a media player for Windows. Similar like VLC mpv.net is not based on DirectShow like MPC, mpv.net is based on libmpv which in return is based on ffmpeg.
mpv.net is a modern media player for Windows. mpv is similar to VLC not based on DirectShow like MPC, mpv.net is based on libmpv which in return is based on ffmpeg.
libmpv provides the majority of the features of the mpv media player, a fork of mplayer. mpv focuses on the usage of the command line interface, mpv.net retains the ability to be used from the command line and adds a simple and easy to use GUI on top of it.
libmpv provides the majority of the features of the mpv media player, a fork of mplayer. mpv focuses on the usage of the command line interface, mpv.net retains the ability to be used from the command line and adds a modern GUI on top of it.
mpv.net is meant to be a small single person project, it's designed to be mpv compatible, can use the same settings as mpv and offers almost all mpv features because they are all contained in libmpv, this means the official [mpv manual](https://mpv.io/manual/master/) fully applies to mpv.net.
@@ -119,7 +120,7 @@ If you are new to mpv.net the portable download is recommended, for regular mpv.
The x64 editions require more memory and have the advantage of decoders being typically first and better optimized for x64.
x86 should though still be well supported and work.
x86 should though still be well supported and work but it's not as well tested than x64.
### File Associations
@@ -129,6 +130,16 @@ Windows 10 prevents apps to register as the default app, to define the default v
It's also possible to change the default application using the Open With feature of the context menu in Windows File Explorer.
### Chrome Extension
In order to play videos from sites such as YouTube the Chrome Extension [Play with mpv](https://chrome.google.com/webstore/detail/play-with-mpv/hahklcmnfgffdlchjigehabfbiigleji) can be used.
Due to Chrome Extensions not being able to start a app, another app that communicates with the extension is required, this app can be downloaded [here](http://www.mediafire.com/file/6tmwdjsfknhmsxy/play-with-mpvnet-server.7z/file). The extension works only when the app is running, to have the app always running a link can be created in the auto start folder located at:
`C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup`
This will start the app on system start and have it running in the background. When the file association registration of mpv.net was executed then the app should find the location of mpv.net, alternativly the mpv.net folder can be added to the PATH environment variable.
## Context Menu
The most important part of the user interface in mpv.net is the context menu, the menu can be customized as it is defined in the same file where the key bindings are defined.
@@ -141,11 +152,15 @@ Another way to open files is the command line, it is used by the Windows File Ex
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.
### Open > Open URL
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.
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.
### Open > Show media search

View File

@@ -52,12 +52,13 @@ Table of contents
- Searchable command palette to quickly launch commands and look for keys ([Screenshot](#command-palette-screenshot))
- Modern UI with dark mode ([Screenshot](#config-editor-screenshot))
- Addon/extension API for .NET languages
- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([wiki](https://github.com/stax76/mpv.net/wiki/Scripting))
- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([Wiki](https://github.com/stax76/mpv.net/wiki/Scripting))
- mpv's OSC, IPC and conf files
- [Command Line Interface](https://mpv.io/manual/master/#options)
- 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
- Search feature powered by [Everything](https://www.voidtools.com) to find and play media ([Screenshot](#media-search-screenshot))
- Extension to start mpv.net from Google Chrome ([Manual](Manual.md#chrome-extension))
### Screenshots
@@ -86,7 +87,7 @@ A searchable key and mouse binding editor.
#### Command Palette Screenshot
Forgot where a command in the menu is located or what shortcut key it has?
Just press Ctrl+Shift+P and find it easily in the searchable command palette.
Just press F1 and find it easily in the searchable command palette.
![Command Palette](https://raw.githubusercontent.com/stax76/mpv.net/master/img/CommandPalette.png)
@@ -192,6 +193,8 @@ Third party components:
[frank.skare.de@gmail.com](mailto:frank.skare.de@gmail.com?Subject=mpv.net%20support)
Please click on the star at the top of the page and like mpv.net at [alternativeto.net](https://alternativeto.net/software/mpv-net/).
### Links
mpv manual: <https://mpv.io/manual/master/>

View File

@@ -1,4 +1,7 @@
Imports System.ComponentModel.Composition
'this addon implements the C# scripting feature of mpv.net,
'it is based on CS-Script: https://www.cs-script.net/
Imports System.ComponentModel.Composition
Imports System.IO
Imports System.Windows.Forms

View File

@@ -1,4 +1,7 @@
using System;
// this addon writes a rating to the filename of the current video,
// the input.conf defaults contain key bindings for this addon
using System;
using System.ComponentModel.Composition;
using System.Collections.Generic;
using System.IO;
@@ -14,11 +17,11 @@ namespace RatingAddon
public RatingAddon()
{
mp.ClientMessage += mpv_ClientMessage;
mp.Shutdown += mpv_Shutdown;
mp.ClientMessage += ClientMessage; //handles keys defined in input.conf
mp.Shutdown += Shutdown;
}
void mpv_Shutdown()
void Shutdown()
{
foreach (var i in Dic)
{
@@ -44,13 +47,11 @@ namespace RatingAddon
}
}
void mpv_ClientMessage(string[] args)
//handles keys defined in input.conf
void ClientMessage(string[] args)
{
int rating;
if (args?.Length != 2 || args[0] != "rate-file" || ! int.TryParse(args[1], out rating))
if (args[0] != "rate-file" || ! int.TryParse(args[1], out int rating))
return;
Dic[mp.get_property_string("path")] = rating;
mp.commandv("show-text", $"Rating: {rating}");
}

View File

@@ -45,11 +45,11 @@ namespace DynamicGUI
optionSetting.Options.Add(opt);
}
}
else if (setting["default"].IsString)
else
{
StringSetting stringSetting = new StringSetting();
baseSetting = stringSetting;
stringSetting.Default = setting["default"];
stringSetting.Default = setting.HasKey("default") ? setting["default"].ToString() : "";
}
baseSetting.Name = setting["name"];

View File

@@ -64,7 +64,8 @@ namespace DynamicGUI
{
d.FullOpen = true;
try {
d.Color = System.Drawing.ColorTranslator.FromHtml(ValueTextBox.Text);
Color col = GetColor(ValueTextBox.Text);
d.Color = System.Drawing.Color.FromArgb(col.A, col.R, col.G, col.B);
} catch { }
if (d.ShowDialog() == WinForms.DialogResult.OK)
ValueTextBox.Text = System.Drawing.ColorTranslator.ToHtml(d.Color);
@@ -75,29 +76,31 @@ namespace DynamicGUI
private void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e) => Update();
Color GetColor(string value)
{
if (value.Contains("/"))
{
string[] a = value.Split('/');
if (a.Length == 3)
return Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
else if (a.Length == 4)
return Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
}
return (Color)ColorConverter.ConvertFromString(value);
Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
}
public void Update()
{
if (StringSetting.Type == "color")
{
Color c = Colors.Transparent;
if (ValueTextBox.Text != "")
{
try {
if (ValueTextBox.Text.Contains("/"))
{
string[] a = ValueTextBox.Text.Split('/');
if (a.Length == 3)
c = Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
else if (a.Length == 4)
c = Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
}
else
c = (Color)ColorConverter.ConvertFromString(ValueTextBox.Text);
} catch {}
}
if (ValueTextBox.Text != "") try { c = GetColor(ValueTextBox.Text); } catch {}
ValueTextBox.Background = new SolidColorBrush(c);
}
Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
}
}
}

View File

@@ -1752,7 +1752,6 @@ namespace Tommy
}
else
stringBuilder.Append(c);
break;
}
}

View File

@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
@@ -13,96 +12,61 @@ namespace mpvnet
{
public class Command
{
public string Name { get; set; }
public Action<string[]> Action { get; set; }
static List<Command> commands;
public static List<Command> Commands
public static void Execute(string id, string[] args)
{
get
switch (id)
{
if (commands == null)
{
commands = new List<Command>();
Type type = typeof(Command);
MethodInfo[] methods = type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
foreach (MethodInfo i in methods)
{
ParameterInfo[] parameters = i.GetParameters();
if (parameters == null || parameters.Length != 1 || parameters[0].ParameterType != typeof(string[]))
continue;
Command cmd = new Command() { Name = i.Name.Replace("_","-"), Action = (Action<string[]>)i.CreateDelegate(typeof(Action<string[]>)) };
commands.Add(cmd);
}
}
return commands;
case "manage-file-associations": ManageFileAssociations(); break;
case "cycle-audio": CycleAudio(); break;
case "load-audio": LoadAudio(); break;
case "load-sub": LoadSubtitle(); break;
case "open-url": OpenURL(); break;
case "execute-mpv-command": ExecuteMpvCommand(); break;
case "show-history": ShowHistory(); break;
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
case "show-command-palette": ShowDialog(typeof(CommandPaletteWindow)); break;
case "show-about": ShowDialog(typeof(AboutWindow)); break;
case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break;
case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
case "open-conf-folder": Process.Start(mp.ConfFolder); break;
case "open-files": OpenFiles(args); break;
case "shell-execute": Process.Start(args[0]); break;
case "show-info": ShowInfo(); break;
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
default: Msg.ShowError($"No command '{id}' found."); break;
}
}
public static void open_files(string[] args)
public static void InvokeOnMainThread(Action action) => MainForm.Instance.Invoke(action);
public static void ShowDialog(Type winType)
{
MainForm.Instance.Invoke(new Action(() => {
InvokeOnMainThread(new Action(() => {
Window win = Activator.CreateInstance(winType) as Window;
new WindowInteropHelper(win).Owner = MainForm.Instance.Handle;
win.ShowDialog();
}));
}
public static void OpenFiles(params string[] args)
{
bool append = Control.ModifierKeys.HasFlag(Keys.Control);
bool loadFolder = true;
foreach (string arg in args)
{
if (arg == "append") append = true;
if (arg == "no-folder") loadFolder = false;
}
InvokeOnMainThread(new Action(() => {
using (var d = new OpenFileDialog() { Multiselect = true })
if (d.ShowDialog() == DialogResult.OK)
mp.Load(d.FileNames);
mp.Load(d.FileNames, loadFolder, append);
}));
}
public static void open_conf_folder(string[] args)
{
Process.Start(mp.ConfFolder);
}
public static void show_input_editor(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
InputWindow w = new InputWindow();
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
w.ShowDialog();
}));
}
public static void show_conf_editor(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
ConfWindow w = new ConfWindow();
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
w.ShowDialog();
}));
}
public static void show_about(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
AboutWindow w = new AboutWindow();
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
w.ShowDialog();
}));
}
public static void show_command_palette(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
var w = new CommandPaletteWindow();
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
w.ShowDialog();
}));
}
public static void show_media_search(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
var w = new EverythingWindow();
new WindowInteropHelper(w).Owner = MainForm.Instance.Handle;
w.ShowDialog();
}));
}
public static void show_history(string[] args)
public static void ShowHistory()
{
var fp = mp.ConfFolder + "history.txt";
@@ -114,9 +78,7 @@ namespace mpvnet
File.WriteAllText(fp, "");
}
public static void shell_execute(string[] args) => Process.Start(args[0]);
public static void show_info(string[] args)
public static void ShowInfo()
{
try
{
@@ -180,28 +142,32 @@ namespace mpvnet
}
}
public static void execute_mpv_command(string[] args)
public static void ExecuteMpvCommand()
{
MainForm.Instance.Invoke(new Action(() => {
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString(App.RegPath, "RecentExecutedCommand"));
InvokeOnMainThread(new Action(() => {
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegHelp.GetString(App.RegPath, "RecentExecutedCommand"));
if (string.IsNullOrEmpty(command)) return;
RegistryHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
RegHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
mp.command_string(command, false);
}));
}
public static void open_url(string[] args)
public static void OpenURL()
{
MainForm.Instance.Invoke(new Action(() => {
string command = VB.Interaction.InputBox("Enter URL to be opened.");
if (string.IsNullOrEmpty(command)) return;
mp.Load(command);
InvokeOnMainThread(new Action(() => {
string clipboard = System.Windows.Forms.Clipboard.GetText();
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) || clipboard.Contains("\n"))
{
Msg.ShowError("The clipboard does not contain a valid URL or file, URLs have to contain :// and are not allowed to contain a newline character.");
return;
}
mp.Load(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
}));
}
public static void load_sub(string[] args)
public static void LoadSubtitle()
{
MainForm.Instance.Invoke(new Action(() => {
InvokeOnMainThread(new Action(() => {
using (var d = new OpenFileDialog())
{
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
@@ -213,9 +179,9 @@ namespace mpvnet
}));
}
public static void load_audio(string[] args)
public static void LoadAudio()
{
MainForm.Instance.Invoke(new Action(() => {
InvokeOnMainThread(new Action(() => {
using (var d = new OpenFileDialog())
{
d.InitialDirectory = Path.GetDirectoryName(mp.get_property_string("path", false));
@@ -228,17 +194,7 @@ namespace mpvnet
}));
}
public static void add_files_to_playlist(string[] args)
{
MainForm.Instance.Invoke(new Action(() => {
using (var d = new OpenFileDialog() { Multiselect = true })
if (d.ShowDialog() == DialogResult.OK)
foreach(string file in d.FileNames)
mp.commandv("loadfile", file, "append");
}));
}
public static void cycle_audio(string[] args)
public static void CycleAudio()
{
string filePath = mp.get_property_string("path", false);
if (!File.Exists(filePath)) return;
@@ -255,7 +211,7 @@ namespace mpvnet
}
}
public static void manage_file_associations(string[] args)
public static void ManageFileAssociations()
{
using (var td = new TaskDialog<string>())
{
@@ -264,7 +220,7 @@ namespace mpvnet
td.AddCommandLink("Register video file extensions", "video");
td.AddCommandLink("Register audio file extensions", "audio");
td.AddCommandLink("Unregister file extensions", "unreg");
td.AddCommandLink("Unregister file extensions", "unreg");
string result = td.Show();
@@ -272,14 +228,10 @@ namespace mpvnet
{
using (var proc = new Process())
{
proc.StartInfo.FileName = Application.ExecutablePath;
proc.StartInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
proc.StartInfo.Arguments = "--reg-file-assoc " + result;
proc.StartInfo.Verb = "runas";
try {
proc.Start();
}
catch (Exception)
{ }
try { proc.Start(); } catch { }
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -18,15 +19,16 @@ namespace mpvnet
public class App
{
public static string ConfFilePath { get; } = mp.ConfFolder + "\\mpvnet.conf";
public static string RegPath { get; } = "HKCU\\Software\\" + Application.ProductName;
public static string ClipboardMonitoring { get; set; } = "yes";
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
public static string DarkMode { get; set; } = "always";
public static string ProcessInstance { get; set; } = "single";
public static string[] VideoTypes { get; } = "mkv mp4 mpg avi mov webm vob wmv flv avs 264 h264 asf webm mpeg mpv y4m avc hevc 265 h265 m2v m2ts vpy mts m4v".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[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
public static string DarkMode { get; set; } = "always";
public static string ProcessInstance { get; set; } = "single";
public static bool DebugMode { get; set; } = false;
public static bool IsDarkMode {
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
@@ -36,6 +38,28 @@ namespace mpvnet
{
foreach (var i in Conf)
ProcessProperty(i.Key, i.Value);
if (App.DebugMode)
{
try
{
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\mpvnet-debug.log";
if (File.Exists(filePath)) File.Delete(filePath);
Trace.Listeners.Clear();
Trace.Listeners.Add(new TextWriterTraceListener(filePath));
foreach (Screen screen in Screen.AllScreens)
Trace.WriteLine(screen);
}
catch (Exception e)
{
Msg.ShowException(e);
}
}
}
public static void Exit()
{
if (Trace.Listeners.Count > 0) Trace.Listeners[0].Close();
}
static Dictionary<string, string> _Conf;
@@ -59,9 +83,12 @@ namespace mpvnet
{
switch (name)
{
case "clipboard-monitoring": ClipboardMonitoring = value; break;
case "process-instance": ProcessInstance = value; break;
case "dark-mode": DarkMode = value; break;
case "debug-mode": DebugMode = value == "yes"; break;
case "url-whitelist":
UrlWhitelist = value.Split(' ', ',', ';');
break;
}
}
@@ -82,15 +109,9 @@ namespace mpvnet
}
else
{
string switchName = i.Substring(2);
switch (switchName)
{
case "fs":
case "fullscreen":
mp.Fullscreen = true;
break;
}
string name = i.Substring(2);
mp.ProcessProperty(name, "yes");
ProcessProperty(name, "yes");
}
}
}
@@ -144,49 +165,49 @@ namespace mpvnet
{
Types = types;
RegistryHelp.SetObject(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath);
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player");
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player");
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net");
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, "");
RegistryHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, "");
RegHelp.SetObject(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath);
RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player");
RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationDescription", "mpv.net media player");
RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv\Capabilities", "ApplicationName", "mpv.net");
RegHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, "");
RegHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, "");
foreach (string ext in Types)
{
RegistryHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, "");
RegistryHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
RegistryHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, "");
RegHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
RegHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
if (App.VideoTypes.Contains(ext))
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video");
RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video");
if (App.AudioTypes.Contains(ext))
RegistryHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio");
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName);
RegistryHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
RegistryHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio");
RegHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName);
RegHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\"");
RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
}
}
public static void Unregister()
{
RegistryHelp.RemoveKey(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
RegistryHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}");
RegistryHelp.RemoveKey(@"HKLM\SOFTWARE\Clients\Media\mpv.net");
RegistryHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}");
RegistryHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}");
RegHelp.RemoveKey(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
RegHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}");
RegHelp.RemoveKey(@"HKLM\SOFTWARE\Clients\Media\mpv.net");
RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}");
RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}");
foreach (string id in Registry.ClassesRoot.GetSubKeyNames())
{
if (id.StartsWith(ExeFilenameNoExt + "."))
Registry.ClassesRoot.DeleteSubKeyTree(id);
RegistryHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
RegistryHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
RegHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
RegHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
}
}
}
public class RegistryHelp
public class RegHelp
{
public static void SetObject(string path, string name, object value)
{
@@ -201,6 +222,13 @@ namespace mpvnet
return val.ToString();
}
public static int GetInt(string path, string name)
{
object val = GetObject(path, name);
if (val == null || !(val is int)) return 0;
return (int)val;
}
public static object GetObject(string path, string name)
{
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5)))
@@ -212,14 +240,18 @@ namespace mpvnet
public static void RemoveKey(string path)
{
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
try {
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
} catch { }
}
public static void RemoveValue(string path, string name)
{
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true))
if (!(rk is null))
rk.DeleteValue(name, false);
try {
using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true))
if (!(rk is null))
rk.DeleteValue(name, false);
} catch {}
}
static RegistryKey GetRootKey(string path)
@@ -362,15 +394,4 @@ namespace mpvnet
Math.Abs(screenPos.Y - Control.MousePosition.Y) > 10;
}
}
public class SingleProcess
{
public static int Message { get; } = RegisterWindowMessage("mpvnet_IPC");
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern int RegisterWindowMessage(string id);
[DllImport("user32.dll")]
public static extern bool AllowSetForegroundWindow(int dwProcessId);
}
}

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace mpvnet
{
@@ -13,8 +14,6 @@ namespace mpvnet
[STAThread]
static void Main()
{
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
try
{
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
@@ -28,43 +27,49 @@ namespace mpvnet
}
App.Init();
Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst);
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
{
List<string> files = new List<string>();
files.Add(App.ProcessInstance);
foreach (string arg in args)
if (!arg.StartsWith("--") && (File.Exists(arg) || arg == "-" || arg.StartsWith("http")))
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg)))
files.Add(arg);
if (files.Count > 0)
RegistryHelp.SetObject(App.RegPath, "ShellFiles", files.ToArray());
Process[] procs = Process.GetProcessesByName("mpvnet");
RegistryHelp.SetObject(App.RegPath, "ProcessInstanceMode", App.ProcessInstance);
foreach(Process process in Process.GetProcessesByName("mpvnet"))
for (int i = 0; i < 20; i++)
{
try {
SingleProcess.AllowSetForegroundWindow(process.Id);
Native.SendMessage(process.MainWindowHandle, SingleProcess.Message, IntPtr.Zero, IntPtr.Zero);
} catch {}
foreach (Process proc in procs)
{
if (proc.MainWindowHandle != IntPtr.Zero)
{
Native.AllowSetForegroundWindow(proc.Id);
var data = new Native.COPYDATASTRUCT();
data.lpData = string.Join("\n", files.ToArray());
data.cbData = data.lpData.Length * 2 + 1;
Native.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
mutex.Dispose();
return;
}
}
Thread.Sleep(50);
}
mutex.Dispose();
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
mutex.Dispose();
}
catch (Exception ex)
{
Msg.ShowException(ex);
}
finally
{
mutex.Dispose();
}
}
}
}

View File

@@ -15,9 +15,15 @@ namespace mpvnet
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
public static extern bool AllowSetForegroundWindow(int dwProcessId);
[DllImport("user32.dll")]
public static extern void ReleaseCapture();
@@ -70,5 +76,14 @@ namespace mpvnet
public int Width => Right - Left;
public int Height => Bottom - Top;
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cbData;
[MarshalAs(UnmanagedType.LPStr)]
public string lpData;
}
}
}

View File

@@ -6,9 +6,9 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("mpv.net")]
[assembly: AssemblyDescription("A modern media player")]
[assembly: AssemblyDescription("media player")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Frank Skare (stax76)")]
[assembly: AssemblyProduct("mpv.net")]
[assembly: AssemblyCopyright("Copyright © 2017-2019 Frank Skare (stax76)")]
[assembly: AssemblyTrademark("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyFileVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.6.0.0")]
[assembly: AssemblyFileVersion("4.6.0.0")]

View File

@@ -84,31 +84,9 @@ namespace mpvnet.Properties {
/// <summary>
/// Looks up a localized string similar to
/// # This file defines the input (keys and mouse) bindings of mpv and mpv.net
/// # and it also defines the context menu of mpv.net. mpv.net has an input
/// # editor and an config editor as alternatives to editing conf text files.
/// # The input and config editor can be found in mpv.net&apos;s context menu at:
///# manual: https://mpv.io/manual/master/
///
/// # Settings &gt; Show Config Editor
/// # Settings &gt; 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
///
/// # t [rest of string was truncated]&quot;;.
/// </summary>
internal static string inputConfHeader {
get {
return ResourceManager.GetString("inputConfHeader", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to
///# mpv manual: https://mpv.io/manual/master/
///
///# mpv.net mpv.conf defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
///# defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
///
///input-ar-delay = 500
///input-ar-rate = 20
@@ -116,10 +94,9 @@ namespace mpvnet.Properties {
///hwdec = yes
///keep-open = yes
///keep-open-pause = no
///osd-playing-msg = ${filename}
///screenshot-directory = ~~desktop/
///input-default-bindings = no
///.
///osd-playing-msg = &apos;${filename}&apos;
///screenshot-directory = &apos;~~desktop/&apos;
///input-default-bindings = no.
/// </summary>
internal static string mpvConf {
get {
@@ -164,12 +141,16 @@ namespace mpvnet.Properties {
/// { name = &quot;never&quot; }]
///
///[[settings]]
///name = &quot;clipboard-monitoring&quot;
///default = &quot;yes&quot;
///name = &quot;url-whitelist&quot;
///filter = &quot;mpv.net&quot;
///help = &quot;Monitors the clipboard for URLs to play.&quot;
///options = [{ name = &quot;yes&quot; },
/// { name = &quot;no&quot; }].
///type = &quot;string&quot;
///help = &quot;Whitelist to monitor the clipboard for URLs to play.\n\nDefault: tube vimeo ard zdf&quot;
///
///[[settings]]
///name = &quot;process-instance&quot;
///default = &quot;single&quot;
///filter = &quot;mpv.net&quot;
///help = &quot;Defines [rest of string was truncated]&quot;;.
/// </summary>
internal static string mpvNetConfToml {
get {

View File

@@ -121,9 +121,6 @@
<data name="inputConf" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\inputConf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="inputConfHeader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\inputConfHeader.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="mpvConf" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mpvConf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>

View File

@@ -25,13 +25,13 @@
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys
o script-message mpv.net open-files #menu: Open > Open Files...
u script-message mpv.net open-url #menu: Open > Open URL...
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
_ ignore #menu: Open > -
Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files...
Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files...
_ ignore #menu: Open > -
_ script-message mpv.net add-files-to-playlist #menu: Open > Add files to playlist...
Ctrl+S 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...
F3 script-message mpv.net show-media-search #menu: Open > Show media search...
_ ignore #menu: Open > -
_ ignore #menu: Open > Recent
@@ -132,6 +132,7 @@
Ctrl+t set ontop yes #menu: View > On Top > Enable
Ctrl+T set ontop no #menu: View > On Top > Disable
b cycle border #menu: View > Toggle Border
i script-message mpv.net show-info #menu: View > File Info
t script-binding stats/display-stats #menu: View > Show Statistics
T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics
@@ -143,11 +144,11 @@
Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor
Ctrl+f script-message mpv.net open-conf-folder #menu: Settings > Open Config Folder
Ctrl+P script-message mpv.net show-command-palette #menu: Tools > Command Palette
F1 script-message mpv.net show-command-palette #menu: Tools > Show All Commands
h script-message mpv.net show-history #menu: Tools > Show History
l ab-loop #menu: Tools > Set/clear A-B loop points
L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Cycle Hardware Decoding
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Toggle Hardware Decoding
_ script-message mpv.net execute-mpv-command #menu: Tools > Execute mpv command...
_ script-message mpv.net manage-file-associations #menu: Tools > Manage File Associations...
@@ -179,5 +180,6 @@
Wheel_Down add volume -10
Prev playlist-prev
Next playlist-next
Ctrl+Wheel_Up no-osd seek 7
Ctrl+Wheel_Down no-osd seek -7
MBTN_LEFT_DBL cycle fullscreen

View File

@@ -1,25 +0,0 @@
# This file defines the input (keys and mouse) bindings of mpv and mpv.net
# and it also defines the context menu of mpv.net. mpv.net has an input
# editor and an config editor as alternatives to editing conf text files.
# 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
# the defaults of mpv can be found at:
# https://github.com/mpv-player/mpv/blob/master/etc/inputConf
# mpv.net's defaults of mpv.conf contain: 'input-default-bindings = no'
# which disables mpv's input defaults. Every line in this file begins with a
# space character to make it easier to do a text search, so if you want to know
# if 'o' has already a binding you can make a text search on ' o '.
# mpv input commands: https://github.com/stax76/mpv.net/wiki/mpv-input-commands
# mpv input keys: https://github.com/stax76/mpv.net/wiki/mpv-input-keys

View File

@@ -1,7 +1,7 @@
# mpv manual: https://mpv.io/manual/master/
# manual: https://mpv.io/manual/master/
# mpv.net mpv.conf defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
# defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpvConf.txt
input-ar-delay = 500
input-ar-rate = 20
@@ -9,6 +9,7 @@ volume = 50
hwdec = yes
keep-open = yes
keep-open-pause = no
osd-playing-msg = ${filename}
screenshot-directory = ~~desktop/
osd-playing-msg = '${filename}'
screenshot-directory = '~~desktop/'
input-default-bindings = no
script-opts=osc-scalewindowed=1.5

View File

@@ -147,8 +147,8 @@ help = "Set the startup volume. 0 means silence, 100 means no volume reduction o
[[settings]]
name = "alang"
default = ""
filter = "Audio"
type = "string"
help = "Specify a priority list of audio languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two-letter language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter language codes, while OGM uses a free-form identifier. See also aid.\n\nExamples\n\nmpv dvd://1 alang=hu,en chooses the Hungarian language track on a DVD and falls back on English if Hungarian is not available.\n\nmpv alang=jpn example.mkv plays a Matroska file with Japanese audio."
[[settings]]
@@ -163,8 +163,8 @@ options = [{ name = "no", help = "Don't automatically load external audio fil
[[settings]]
name = "slang"
default = ""
filter = "Subtitle"
type = "string"
help = "Specify a priority list of subtitle languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two letter language codes, Matroska uses ISO 639-2 three letter language codes while OGM uses a free-form identifier. See also sid."
[[settings]]
@@ -179,57 +179,33 @@ options = [{ name = "no", help = "Don't automatically load external subtitle
[[settings]]
name = "sub-font"
default = ""
filter = "Subtitle"
type = "string"
help = "Specify font to use for subtitles that do not themselves specify a particular font. The default is sans-serif."
[[settings]]
name = "sub-font-size"
default = ""
filter = "Subtitle"
help = "Specify the sub font size. The unit is the size in scaled pixels at a window height of 720. The actual pixel size is scaled with the window height: if the window height is larger or smaller than 720, the actual size of the text increases or decreases as well. Default: 55"
[[settings]]
name = "sub-color"
default = ""
type = "color"
filter = "Subtitle"
help = "Specify the color used for unstyled text subtitles.\n\nThe color is specified in the form r/g/b, where each color component is specified as number in the range 0.0 to 1.0. It's also possible to specify the transparency by using r/g/b/a, where the alpha value 0 means fully transparent, and 1.0 means opaque. If the alpha component is not given, the color is 100% opaque.\n\nPassing a single number to the option sets the sub to gray, and the form gray/a lets you specify alpha additionally.\n\nExamples\n\n1.0/0.0/0.0 set sub to opaque red\n1.0/0.0/0.0/0.75 set sub to opaque red with 75% alpha\n0.5/0.75 set sub to 50% gray with 75% alpha\n\nAlternatively, the color can be specified as a RGB hex triplet in the form #RRGGBB, where each 2-digit group expresses a color value in the range 0 (00) to 255 (FF). For example, #FF0000 is red. This is similar to web colors. Alpha is given with #AARRGGBB.\n\nExamples\n\n#FF0000 set sub to opaque red\n#C0808080 set sub to 50% gray with 75% alpha"
[[settings]]
name = "sub-border-color"
default = ""
type = "color"
filter = "Subtitle"
help = "See sub-color. Color used for the sub font border. Ignored when sub-back-color is specified (or more exactly: when that option is not set to completely transparent)."
[[settings]]
name = "sub-back-color"
default = ""
type = "color"
filter = "Subtitle"
help = "See sub-color. Color used for sub text background. You can use sub-shadow-offset to change its size relative to the text."
[[settings]]
name = "screen"
default = ""
filter = "Screen"
help = "In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on."
[[settings]]
name = "osd-playing-msg"
default = ""
width = 300
filter = "Screen"
help = "Show a message on OSD when playback starts. The string is expanded for properties, e.g. osd-playing-msg='file: ${filename}' will show the message file: followed by a space and the currently played filename. For more information visit:"
helpurl = "https://mpv.io/manual/master/#property-expansion"
[[settings]]
name = "osd-font-size"
default = "55"
filter = "Screen"
help = "Specify the OSD font size. See sub-font-size for details. Default: 55"
[[settings]]
name = "fullscreen"
default = "no"
@@ -238,9 +214,35 @@ help = "Start the player in fullscreen mode."
options = [{ name = "yes" },
{ name = "no" }]
[[settings]]
name = "border"
default = "yes"
filter = "Screen"
help = "Show window with decoration (titlebar, border)."
options = [{ name = "yes" },
{ name = "no" }]
[[settings]]
name = "screen"
filter = "Screen"
help = "<0-32> In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on."
[[settings]]
name = "osd-playing-msg"
width = 300
filter = "Screen"
type = "string"
help = "Show a message on OSD when playback starts. The string is expanded for properties, e.g. osd-playing-msg='file: ${filename}' will show the message file: followed by a space and the currently played filename. For more information visit:"
helpurl = "https://mpv.io/manual/master/#property-expansion"
[[settings]]
name = "osd-font-size"
default = "55"
filter = "Screen"
help = "Specify the OSD font size. See sub-font-size for details. Default: 55"
[[settings]]
name = "screenshot-directory"
default = ""
width = 500
type = "folder"
filter = "Screen"
@@ -252,6 +254,14 @@ default = "50%"
filter = "Screen"
help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%"
[[settings]]
name = "remember-height"
default = "yes"
filter = "Screen"
help = "mpv.net specific setting to remember the window height, otherwise the video's native resolution is used."
options = [{ name = "yes" },
{ name = "no" }]
[[settings]]
name = "keep-open-pause"
default = "yes"
@@ -271,7 +281,6 @@ options = [{ name = "yes", help = "Don't terminate if the current file is the
[[settings]]
name = "loop-file"
default = ""
filter = "Playback"
help = "Loop a single file N times. inf means forever, no means normal playback.\n\nThe difference to loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file. loop is an alias for this option."
@@ -285,13 +294,11 @@ options = [{ name = "yes" },
[[settings]]
name = "input-ar-delay"
default = ""
filter = "Input"
help = "Delay in milliseconds before we start to autorepeat a key (0 to disable)."
[[settings]]
name = "input-ar-rate"
default = ""
filter = "Input"
help = "Number of key presses to generate per second on autorepeat."
@@ -315,6 +322,5 @@ options = [{ name = "yes" },
[[settings]]
name = "loop-playlist"
default = ""
filter = "Playback"
help = "<N|inf|force|no> Loops playback N times. A value of 1 plays it one time (default), 2 two times, etc. inf means forever. no is the same as 1 and disables looping. If several files are specified on command line, the entire playlist is looped. The force mode is like inf, but does not skip playlist entries which have been marked as failing. This means the player might waste CPU time trying to loop a file that doesn't exist. But it might be useful for playing webradios under very bad network conditions."

View File

@@ -1,25 +1,31 @@
[[settings]]
name = "dark-mode"
default = "always"
filter = "mpv.net"
filter = "General"
help = "Enables a dark theme."
options = [{ name = "always" },
{ name = "system" , help = "Available on Windows 10 or higher" },
{ name = "never" }]
[[settings]]
name = "clipboard-monitoring"
default = "yes"
filter = "mpv.net"
help = "Monitors the clipboard for URLs to play."
options = [{ name = "yes" },
{ name = "no" }]
name = "url-whitelist"
filter = "General"
type = "string"
help = "mpv.net specific whitelist setting to monitor the clipboard for URLs to play.\n\nDefault: tube vimeo ard zdf"
[[settings]]
name = "process-instance"
default = "single"
filter = "mpv.net"
help = "Defines if more then one mpv.net process is allowed."
filter = "General"
help = "mpv.net specific setting that defines if more then one mpv.net process is allowed.\n\nTip: 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."
options = [{ name = "multi", help = "Create a new process everytime the shell starts mpv.net" },
{ name = "single", help = "Force a single process everytime the shell starts mpv.net" },
{ 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]]
name = "debug-mode"
default = "no"
filter = "General"
help = "mpv.net specific setting that writes debug info to a file located on the desktop."
options = [{ name = "yes" },
{ name = "no" }]

View File

@@ -14,26 +14,27 @@ namespace mpvnet
using (Runspace runspace = RunspaceFactory.CreateRunspace())
{
runspace.ApartmentState = ApartmentState.STA;
runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;
runspace.Open();
using (Pipeline pipeline = runspace.CreatePipeline())
{
pipeline.Commands.AddScript(
@"Using namespace mpvnet;
Using namespace System;
[System.Reflection.Assembly]::LoadWithPartialName(""mpvnet"")");
"Using namespace mpvnet\n" +
"Using namespace System\n" +
"[System.Reflection.Assembly]::LoadWithPartialName(\"mpvnet\")\n");
pipeline.Commands.AddScript(code);
if (parameters != null)
foreach (var i in parameters)
pipeline.Commands[1].Parameters.Add(null, i);
try
{
var ret = pipeline.Invoke(parameters);
if (ret.Count > 0)
return ret[0];
var ret = pipeline.Invoke();
if (ret.Count > 0) return ret[0];
}
catch (Exception ex)
catch (Exception e)
{
try
{
@@ -46,12 +47,12 @@ Using namespace System;
throw new Exception();
}
}
catch (Exception ex2)
catch (Exception e2)
{
Msg.ShowError("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", ex2.ToString());
Msg.ShowError("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", e2.ToString());
return null;
}
Msg.ShowException(ex);
Msg.ShowException(e);
}
}
}
@@ -70,17 +71,11 @@ Using namespace System;
eventObject.FilePath = filePath;
if (eventInfo.EventHandlerType == typeof(Action))
{
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke));
}
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
{
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeEndFileEventMode));
}
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
{
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings));
}
else
throw new Exception();
@@ -91,10 +86,7 @@ Using namespace System;
return;
}
}
Task.Run(() =>
{
PowerShellScript.Execute(File.ReadAllText(filePath), new string[] {});
});
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(filePath), null));
}
}
@@ -104,24 +96,16 @@ Using namespace System;
public Delegate Delegate { get; set; }
public string FilePath { get; set; }
public void Invoke()
{
Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { }); });
}
public void Invoke() => Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), null); });
public void InvokeEndFileEventMode(EndFileEventMode arg)
{
Task.Run(() =>
{
PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { arg.ToString() });
});
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), new [] { arg.ToString() }));
}
public void InvokeStrings(string[] args)
{
Task.Run(() => {
PowerShellScript.Execute(File.ReadAllText(FilePath), args);
});
Task.Run(() => PowerShellScript.Execute(File.ReadAllText(FilePath), args));
}
}
}

View File

@@ -28,7 +28,7 @@ namespace mpvnet
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
LoadSettings(SettingsDefinitions, Conf);
LoadSettings(NetSettingsDefinitions, NetConf);
SearchControl.Text = RegistryHelp.GetString(@"HKCU\Software\mpv.net", "config editor search");
SearchControl.Text = RegHelp.GetString(App.RegPath, "config editor search");
if (App.IsDarkMode)
{
@@ -49,7 +49,7 @@ namespace mpvnet
private void LoadSettings(List<SettingBase> settingsDefinitions,
Dictionary<string, string> confSettings)
{
foreach (var setting in settingsDefinitions)
foreach (SettingBase setting in settingsDefinitions)
{
if (!FilterStrings.Contains(setting.Filter))
FilterStrings.Add(setting.Filter);
@@ -58,8 +58,8 @@ namespace mpvnet
{
if (setting.Name == pair.Key)
{
setting.Value = pair.Value;
setting.StartValue = pair.Value;
setting.Value = pair.Value.Trim('\'', '"');
setting.StartValue = pair.Value.Trim('\'', '"');
continue;
}
}
@@ -132,7 +132,7 @@ namespace mpvnet
{
base.OnClosed(e);
WriteToDisk();
RegistryHelp.SetObject(@"HKCU\Software\mpv.net", "config editor search", SearchControl.Text);
RegHelp.SetObject(App.RegPath, "config editor search", SearchControl.Text);
}
void WriteToDisk()
@@ -165,17 +165,22 @@ namespace mpvnet
foreach (var i in Comments[filePath])
content += $"#{i.Key} = {i.Value}\r\n";
foreach (var setting in settings)
foreach (SettingBase setting in settings)
{
if ((setting.Value ?? "") != setting.Default)
confSettings[setting.Name] = setting.Value;
if (setting.Type == "string" ||
setting.Type == "folder" ||
setting.Type == "color")
confSettings[setting.Name] = "'" + setting.Value + "'";
else
confSettings[setting.Name] = setting.Value;
if (confSettings.ContainsKey(setting.Name) &&
(setting.Value ?? "") == setting.Default ||
(setting.Value ?? "") == "")
{
confSettings.Remove(setting.Name);
}
}
foreach (var i in confSettings)

View File

@@ -95,12 +95,8 @@ namespace mpvnet
ListView.ScrollIntoView(ListView.SelectedItem);
}
break;
case Key.Escape:
Close();
break;
case Key.Enter:
Execute();
break;
case Key.Escape: Close(); break;
case Key.Enter: Execute(); break;
}
}
@@ -113,14 +109,11 @@ namespace mpvnet
void Execute()
{
if (ListView.SelectedItem != null)
mp.Load(ListView.SelectedItem as string);
mp.Load(new[] { ListView.SelectedItem as string }, true, Keyboard.Modifiers == ModifierKeys.Control);
Keyboard.Focus(FilterTextBox);
}
private void ListView_MouseUp(object sender, MouseButtonEventArgs e)
{
Execute();
}
private void ListView_MouseUp(object sender, MouseButtonEventArgs e) => Execute();
private void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
{

View File

@@ -102,7 +102,15 @@ namespace mpvnet
string GetInputConfContent()
{
string text = Properties.Resources.inputConfHeader + "\r\n";
string text = null;
foreach (string line in Properties.Resources.inputConf.Split(new[] { "\r\n" }, StringSplitOptions.None))
{
string test = line.Trim();
if (test == "" || test.StartsWith("#")) text += test + "\r\n";
}
text = "\r\n" + text.Trim() + "\r\n\r\n";
foreach (CommandItem item in CommandItem.Items)
{

View File

@@ -8,7 +8,6 @@ using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Diagnostics;
namespace mpvnet
{
@@ -40,7 +39,7 @@ namespace mpvnet
MinimumSize = new Size(FontHeight * 16, FontHeight * 9);
Text += " " + Application.ProductVersion;
object recent = RegistryHelp.GetObject(App.RegPath, "Recent");
object recent = RegHelp.GetObject(App.RegPath, "Recent");
if (recent is string[] r)
RecentFiles = new List<string>(r);
@@ -49,11 +48,9 @@ namespace mpvnet
var dummy = mp.Conf;
App.ProcessCommandLineEarly();
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
SetScreen(mp.Screen);
ChangeFullscreen(mp.Fullscreen);
CycleFullscreen(mp.Fullscreen);
}
catch (Exception ex)
{
@@ -61,6 +58,24 @@ namespace mpvnet
}
}
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
void Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize()));
void Shutdown() => BeginInvoke(new Action(() => Close()));
void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value)));
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
bool IsFullscreen => WindowState == FormWindowState.Maximized;
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
void ContextMenu_Opening(object sender, CancelEventArgs e)
{
lock (mp.MediaTracks)
@@ -150,10 +165,8 @@ namespace mpvnet
if (recent != null)
{
recent.DropDownItems.Clear();
foreach (string path in RecentFiles)
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(path));
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
recent.DropDownItems.Add(new ToolStripSeparator());
MenuItem mi = new MenuItem("Clear List");
mi.Action = () => RecentFiles.Clear();
@@ -161,8 +174,6 @@ namespace mpvnet
}
}
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
MenuItem FindMenuItem(string text, ToolStripItemCollection items)
{
foreach (var item in items)
@@ -211,22 +222,36 @@ namespace mpvnet
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
}
void SetFormPositionAndSizeKeepHeight()
void SetFormPosAndSize()
{
if (IsFullscreen || mp.VideoSize.Width == 0) return;
if (IsFullscreen)
return;
Size size = mp.VideoSize;
Screen screen = Screen.FromControl(this);
int height = ClientSize.Height;
if (height > screen.Bounds.Height * 0.9) height = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
int fixedHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit);
if (size.Height == 0 || size.Width == 0 || size.Width / (float)size.Height < 1.2)
{
size.Height = fixedHeight;
size.Width = (int)(fixedHeight * 1.8);
}
int height = size.Height;
if (mp.RememberHeight)
height = ClientSize.Height;
if (height > screen.Bounds.Height * 0.9)
height = fixedHeight;
int width = Convert.ToInt32(height * size.Width / (double)size.Height);
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
var rect = new Native.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
NativeHelp.AddWindowBorders(Handle, ref rect);
int left = middlePos.X - rect.Width / 2;
int top = middlePos.Y - rect.Height / 2;
Screen[] screens = Screen.AllScreens;
if (left < screens[0].Bounds.Left) left = screens[0].Bounds.Left;
int maxLeft = screens[0].Bounds.Left + screens.Select((sc) => sc.Bounds.Width).Sum() - rect.Width - SystemInformation.CaptionHeight;
if (left > maxLeft) left = maxLeft;
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
}
@@ -247,8 +272,7 @@ namespace mpvnet
foreach (CommandItem item in items)
{
if (string.IsNullOrEmpty(item.Path))
continue;
if (string.IsNullOrEmpty(item.Path)) continue;
string path = item.Path.Replace("&", "&&");
MenuItem menuItem = ContextMenu.Add(path, () => {
try {
@@ -257,18 +281,15 @@ namespace mpvnet
Msg.ShowException(ex);
}
});
if (menuItem != null)
menuItem.ShortcutKeyDisplayString = item.Input + " ";
if (menuItem != null) menuItem.ShortcutKeyDisplayString = item.Input + " ";
}
}
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
private void Mp_FileLoaded()
private void FileLoaded()
{
string path = mp.get_property_string("path");
BeginInvoke(new Action(() => {
if (File.Exists(path) || path.StartsWith("http"))
if (File.Exists(path) || path.Contains("://"))
Text = Path.GetFileName(path) + " - mpv.net " + Application.ProductVersion;
else
Text = "mpv.net " + Application.ProductVersion;
@@ -278,10 +299,6 @@ namespace mpvnet
if (RecentFiles.Count > 15) RecentFiles.RemoveAt(15);
}
void Mp_Idle() => BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
Msg.ShowException(e.Exception);
@@ -291,29 +308,12 @@ namespace mpvnet
{
Msg.ShowError(e.ExceptionObject.ToString());
}
void mp_VideoSizeChanged()
public void CycleFullscreen(bool enabled)
{
BeginInvoke(new Action(() => SetFormPositionAndSizeKeepHeight()));
}
void mp_Shutdown()
{
BeginInvoke(new Action(() => Close()));
}
public bool IsFullscreen => WindowState == FormWindowState.Maximized;
void mpPropChangeFullscreen(bool value)
{
BeginInvoke(new Action(() => ChangeFullscreen(value)));
}
void ChangeFullscreen(bool value)
{
if (value)
if (enabled)
{
if (FormBorderStyle != FormBorderStyle.None)
if (WindowState != FormWindowState.Maximized)
{
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
@@ -322,14 +322,19 @@ namespace mpvnet
else
{
WindowState = FormWindowState.Normal;
FormBorderStyle = FormBorderStyle.Sizable;
SetFormPositionAndSizeKeepHeight();
if (mp.Border)
FormBorderStyle = FormBorderStyle.Sizable;
else
FormBorderStyle = FormBorderStyle.None;
SetFormPosAndSize();
}
}
protected override void WndProc(ref Message m)
{
//Debug.WriteLine(m);
//System.Diagnostics.Debug.WriteLine(m);
switch (m.Msg)
{
@@ -340,16 +345,25 @@ namespace mpvnet
case 0x0104: // WM_SYSKEYDOWN
case 0x0105: // WM_SYSKEYUP
case 0x020A: // WM_MOUSEWHEEL
case 0x0207: // WM_MBUTTONDOWN
case 0x0208: // WM_MBUTTONUP
if (mp.WindowHandle != IntPtr.Zero)
Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
break;
case 0x0200: // WM_MOUSEMOVE
Point pos = PointToClient(Cursor.Position);
mp.command_string($"mouse {pos.X} {pos.Y}");
if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show();
break;
case 0x2a3: // WM_MOUSELEAVE
mp.command_string("mouse 1 1"); // osc won't always auto hide
break;
case 0x319: // WM_APPCOMMAND
if (mp.WindowHandle != IntPtr.Zero)
Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
break;
case 0x203: // Native.WM.LBUTTONDBLCLK
if (!IsMouseInOSC())
mp.command_string("cycle fullscreen");
if (!IsMouseInOSC()) mp.command_string("cycle fullscreen");
break;
case 0x02E0: // WM_DPICHANGED
if (IgnoreDpiChanged) break;
@@ -367,37 +381,29 @@ namespace mpvnet
int[] d_corners = { d_w, d_h, -d_w, -d_h };
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
if (corner >= 0)
corners[corner] -= d_corners[corner];
if (corner >= 0) corners[corner] -= d_corners[corner];
Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
m.Result = new IntPtr(1);
return;
}
case 0x004A: // WM_COPYDATA
var copyData = (Native.COPYDATASTRUCT)m.GetLParam(typeof(Native.COPYDATASTRUCT));
string[] files = copyData.lpData.Split('\n');
string mode = files[0];
files = files.Skip(1).ToArray();
if (m.Msg == SingleProcess.Message)
{
object filesObject = RegistryHelp.GetObject(App.RegPath, "ShellFiles");
if (filesObject is string[] files)
{
switch (RegistryHelp.GetString(App.RegPath, "ProcessInstanceMode"))
switch (mode)
{
case "single":
mp.Load(files);
mp.Load(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
break;
case "queue":
foreach (string file in files)
if (File.Exists(file))
mp.commandv("loadfile", file, "append");
mp.commandv("loadfile", file, "append");
break;
}
}
RegistryHelp.RemoveValue(App.RegPath, "ShellFiles");
Activate();
return;
Activate();
return;
}
base.WndProc(ref m);
@@ -414,9 +420,100 @@ namespace mpvnet
{
base.OnDragDrop(e);
if (e.Data.GetDataPresent(DataFormats.FileDrop))
mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[]);
mp.Load(e.Data.GetData(DataFormats.FileDrop) as String[], true, Control.ModifierKeys.HasFlag(Keys.Control));
if (e.Data.GetDataPresent(DataFormats.Text))
mp.Load(e.Data.GetData(DataFormats.Text).ToString());
mp.Load(new[] { e.Data.GetData(DataFormats.Text).ToString() }, true, Control.ModifierKeys.HasFlag(Keys.Control));
}
void Timer_Tick(object sender, EventArgs e)
{
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
{
LastCursorPosChanged = Control.MousePosition;
LastCursorChangedTickCount = Environment.TickCount;
}
else if (Environment.TickCount - LastCursorChangedTickCount > 1500 &&
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
Form.ActiveForm == this && !ContextMenu.Visible)
CursorHelp.Hide();
}
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
void PropChangeAid(string value) => mp.Aid = value;
void PropChangeSid(string value) => mp.Sid = value;
void PropChangeVid(string value) => mp.Vid = value;
void PropChangeEdition(int value) => mp.Edition = value;
void PropChangeBorder(bool enabled) {
mp.Border = enabled;
BeginInvoke(new Action(() => {
if (!IsFullscreen)
{
if (mp.Border && FormBorderStyle == FormBorderStyle.None)
FormBorderStyle = FormBorderStyle.Sizable;
if (!mp.Border && FormBorderStyle == FormBorderStyle.Sizable)
FormBorderStyle = FormBorderStyle.None;
}
}));
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
mp.Init();
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);
mp.Shutdown += Shutdown;
mp.VideoSizeChanged += VideoSizeChanged;
mp.FileLoaded += FileLoaded;
mp.Idle += Idle;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (App.IsDarkMode) ToolStripRendererEx.ColorTheme = Color.Black;
ContextMenu = new ContextMenuStripEx(components);
ContextMenu.Opened += ContextMenu_Opened;
ContextMenu.Opening += ContextMenu_Opening;
BuildMenu();
ContextMenuStrip = ContextMenu;
IgnoreDpiChanged = false;
CheckClipboardForURL();
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
CheckClipboardForURL();
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
Native.SendMessage(Handle, m.Msg, m.WParam, m.LParam);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
if (mp.IsLogoVisible) mp.ShowLogo();
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
RegHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
App.Exit();
mp.commandv("quit");
mp.AutoResetEvent.WaitOne(3000);
}
protected override void OnMouseDown(MouseEventArgs e)
@@ -436,108 +533,27 @@ namespace mpvnet
mp.commandv("quit");
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
mp.command_string($"mouse {e.X} {e.Y}");
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
CursorHelp.Show();
}
bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
void Timer_Tick(object sender, EventArgs e)
{
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
{
LastCursorPosChanged = Control.MousePosition;
LastCursorChangedTickCount = Environment.TickCount;
}
else if (Environment.TickCount - LastCursorChangedTickCount > 1500 &&
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
Form.ActiveForm == this && !ContextMenu.Visible)
{
CursorHelp.Hide();
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
mp.Init();
mp.observe_property_bool("fullscreen", mpPropChangeFullscreen);
mp.observe_property_bool("ontop", mpPropChangeOnTop);
mp.observe_property_string("sid", mpPropChangeSid);
mp.observe_property_string("aid", mpPropChangeAid);
mp.observe_property_string("vid", mpPropChangeVid);
mp.observe_property_int("edition", mpPropChangeEdition);
mp.Shutdown += mp_Shutdown;
mp.VideoSizeChanged += mp_VideoSizeChanged;
mp.FileLoaded += Mp_FileLoaded;
mp.Idle += Mp_Idle;
}
void mpPropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
void mpPropChangeAid(string value) => mp.Aid = value;
void mpPropChangeSid(string value) => mp.Sid = value;
void mpPropChangeVid(string value) => mp.Vid = value;
void mpPropChangeEdition(int value) => mp.Edition = value;
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (App.IsDarkMode) ToolStripRendererEx.ColorTheme = Color.Black;
ContextMenu = new ContextMenuStripEx(components);
ContextMenu.Opened += ContextMenu_Opened;
ContextMenu.Opening += ContextMenu_Opening;
BuildMenu();
ContextMenuStrip = ContextMenu;
IgnoreDpiChanged = false;
CheckURLinClipboard();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
if (mp.IsLogoVisible) mp.ShowLogo();
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
RegistryHelp.SetObject(App.RegPath, "Recent", RecentFiles.ToArray());
mp.commandv("quit");
mp.AutoResetEvent.WaitOne(3000);
}
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
CursorHelp.Show();
}
protected override void OnActivated(EventArgs e)
void CheckClipboardForURL()
{
base.OnActivated(e);
CheckURLinClipboard();
}
void CheckURLinClipboard()
{
if (App.ClipboardMonitoring != "yes") return;
string clipboard = Clipboard.GetText();
if (clipboard.StartsWith("http") && RegistryHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
foreach (string url in App.UrlWhitelist)
{
RegistryHelp.SetObject(App.RegPath, "LastURL", clipboard);
if (clipboard.Contains("://") && ! clipboard.Contains("\n") &&
! clipboard.Contains(" ") && clipboard.Contains(url.ToLower()) &&
RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
{
RegHelp.SetObject(App.RegPath, "LastURL", clipboard);
if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
mp.Load(clipboard);
if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
mp.Load(new[] { clipboard }, true, Control.ModifierKeys.HasFlag(Keys.Control));
}
}
}
}

View File

@@ -260,7 +260,6 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\inputConfHeader.txt" />
<Content Include="Resources\inputConf.txt" />
</ItemGroup>
<ItemGroup>

View File

@@ -144,7 +144,7 @@ namespace mpvnet
MPV_END_FILE_REASON_REDIRECT = 5
}
[StructLayout(LayoutKind.Sequential)]
[StructLayout(LayoutKind.Sequential)]
public struct mpv_event_log_message
{
public string prefix;

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
@@ -65,17 +64,38 @@ namespace mpvnet
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 string InputConfPath { get; } = ConfFolder + "\\input.conf";
public static string ConfPath { get; } = ConfFolder + "\\mpv.conf";
public static bool Fullscreen { get; set; }
public static float Autofit { get; set; } = 0.50f;
public static int Screen { get; set; } = -1;
public static string InputConfPath { get; } = ConfFolder + "\\input.conf";
public static string ConfPath { get; } = ConfFolder + "\\mpv.conf";
public static string Sid { get; set; } = "";
public static string Aid { get; set; } = "";
public static string Vid { get; set; } = "";
public static bool Fullscreen { get; set; }
public static bool Border { get; set; } = true;
public static bool RememberHeight { get; set; } = true;
public static int Screen { get; set; } = -1;
public static int Edition { get; set; }
public static float Autofit { get; set; } = 0.5f;
public static void ProcessProperty(string name, string value)
{
switch (name)
{
case "autofit":
if (value.Length == 3 && value.EndsWith("%"))
if (int.TryParse(value.Substring(0, 2), out int result))
Autofit = result / 100f;
break;
case "fs":
case "fullscreen": Fullscreen = value == "yes"; break;
case "border": Border = value == "yes"; break;
case "screen": Screen = Convert.ToInt32(value); break;
case "remember-height": RememberHeight = value == "yes"; break;
}
}
static string _ConfFolder;
public static string ConfFolder {
@@ -145,8 +165,7 @@ namespace mpvnet
{
string dummy = ConfFolder;
LoadLibrary("mpv-1.dll");
Handle = mpv_create();
set_property_string("input-default-bindings", "yes");
Handle = mpv_create();
set_property_string("osc", "yes");
set_property_string("config", "yes");
set_property_string("wid", MainForm.Hwnd.ToString());
@@ -162,23 +181,22 @@ namespace mpvnet
public static void LoadScripts()
{
string[] jsLua = { ".lua", ".js" };
string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts");
foreach (var scriptPath in startupScripts)
if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower()))
mp.commandv("load-script", $"{scriptPath}");
foreach (string scriptPath in startupScripts)
if (scriptPath.EndsWith(".lua") || scriptPath.EndsWith(".js"))
commandv("load-script", $"{scriptPath}");
foreach (var scriptPath in startupScripts)
foreach (string scriptPath in startupScripts)
if (Path.GetExtension(scriptPath) == ".py")
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
foreach (var scriptPath in startupScripts)
foreach (string scriptPath in startupScripts)
if (Path.GetExtension(scriptPath) == ".ps1")
PowerShellScript.Init(scriptPath);
if (Directory.Exists(mp.ConfFolder + "Scripts"))
foreach (var scriptPath in Directory.GetFiles(mp.ConfFolder + "Scripts"))
if (Directory.Exists(ConfFolder + "Scripts"))
foreach (string scriptPath in Directory.GetFiles(ConfFolder + "Scripts"))
if (Path.GetExtension(scriptPath) == ".py")
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
else if (Path.GetExtension(scriptPath) == ".ps1")
@@ -195,7 +213,7 @@ namespace mpvnet
if (WindowHandle == IntPtr.Zero)
WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
//Debug.WriteLine(evt.event_id.ToString());
//System.Diagnostics.Debug.WriteLine(evt.event_id.ToString());
try
{
@@ -229,7 +247,7 @@ namespace mpvnet
case mpv_event_id.MPV_EVENT_FILE_LOADED:
HideLogo();
FileLoaded?.Invoke();
WriteHistory(mp.get_property_string("path"));
WriteHistory(get_property_string("path"));
break;
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
TracksChanged?.Invoke();
@@ -239,8 +257,7 @@ namespace mpvnet
break;
case mpv_event_id.MPV_EVENT_IDLE:
Idle?.Invoke();
if (mp.get_property_int("playlist-count") == 0)
ShowLogo();
if (get_property_int("playlist-count") == 0) ShowLogo();
break;
case mpv_event_id.MPV_EVENT_PAUSE:
Pause?.Invoke();
@@ -257,31 +274,10 @@ namespace mpvnet
case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE:
var client_messageData = (mpv_event_client_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_client_message));
string[] args = NativeUtf8StrArray2ManagedStrArray(client_messageData.args, client_messageData.num_args);
if (args != null && args.Length > 1 && args[0] == "mpv.net")
{
bool found = false;
foreach (var i in mpvnet.Command.Commands)
{
if (args[1] == i.Name)
{
found = true;
i.Action.Invoke(args.Skip(2).ToArray());
MainForm.Instance.BeginInvoke(new Action(() => {
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
Native.SendMessage(MainForm.Instance.Handle, m.Msg, m.WParam, m.LParam);
}));
}
}
if (!found)
{
List<string> names = mpvnet.Command.Commands.Select((item) => item.Name).ToList();
names.Sort();
Msg.ShowError($"No command '{args[1]}' found.", $"Available commands are:\n\n{string.Join("\n", names)}\n\nHow to bind these commands can be seen in the [default input bindings and menu definition](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt).");
}
}
ClientMessage?.Invoke(args);
if (args.Length > 1 && args[0] == "mpv.net")
Command.Execute(args[1], args.Skip(2).ToArray());
else if (args.Length > 0)
ClientMessage?.Invoke(args);
break;
case mpv_event_id.MPV_EVENT_VIDEO_RECONFIG:
VideoReconfig?.Invoke();
@@ -347,7 +343,7 @@ namespace mpvnet
{
if (IsLogoVisible)
{
mp.commandv("overlay-remove", "0");
commandv("overlay-remove", "0");
IsLogoVisible = false;
}
}
@@ -366,17 +362,11 @@ namespace mpvnet
MethodInfo mi;
if (eventInfo.EventHandlerType == typeof(Action))
{
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.Invoke));
}
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
{
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.InvokeEndFileEventMode));
}
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
{
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.InvokeStrings));
}
else
throw new Exception();
@@ -398,28 +388,19 @@ namespace mpvnet
public static void commandv(params string[] args)
{
if (Handle == IntPtr.Zero)
return;
if (Handle == IntPtr.Zero) return;
IntPtr mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out IntPtr[] byteArrayPointers);
int err = mpv_command(Handle, mainPtr);
if (err < 0)
throw new Exception($"{(mpv_error)err}");
if (err < 0) throw new Exception($"{(mpv_error)err}");
foreach (var ptr in byteArrayPointers)
Marshal.FreeHGlobal(ptr);
Marshal.FreeHGlobal(mainPtr);
}
public static void command_string(string command, bool throwException = false)
{
if (Handle == IntPtr.Zero)
return;
if (Handle == IntPtr.Zero) return;
int err = mpv_command_string(Handle, command);
if (err < 0 && throwException)
throw new Exception($"{(mpv_error)err}\r\n\r\n" + command);
}
@@ -428,7 +409,6 @@ namespace mpvnet
{
byte[] bytes = GetUtf8Bytes(value);
int err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes);
if (err < 0 && throwOnException)
throw new Exception($"{name}: {(mpv_error)err}");
}
@@ -438,18 +418,14 @@ namespace mpvnet
try
{
int err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
if (err < 0 && throwOnException)
throw new Exception($"{name}: {(mpv_error)err}");
if (err < 0 && throwOnException) throw new Exception($"{name}: {(mpv_error)err}");
string ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
return ret;
}
catch (Exception ex)
catch (Exception e)
{
if (throwOnException) throw ex;
if (throwOnException) throw e;
return "";
}
}
@@ -531,77 +507,79 @@ namespace mpvnet
foreach (string i in args)
{
if (!i.StartsWith("--") && (File.Exists(i) || i == "-" || i.StartsWith("http")))
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i)))
{
files.Add(i);
if (i.StartsWith("http"))
RegistryHelp.SetObject(App.RegPath, "LastURL", i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}
mp.Load(files.ToArray());
Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
foreach (string i in args)
{
if (i.StartsWith("--"))
{
if (i.Contains("="))
try
{
string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3);
mp.set_property_string(left, right);
if (i.Contains("="))
{
string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3);
set_property_string(left, right, true);
}
else
set_property_string(i.Substring(2), "yes", true);
}
catch (Exception e)
{
Msg.ShowException(e);
}
else
mp.set_property_string(i.Substring(2), "yes");
}
}
}
public static void Load(params string[] files)
static DateTime LastLoad;
public static void Load(string[] files, bool loadFolder, bool append)
{
if (files is null || files.Length == 0) return;
HideLogo();
List<string> fileList = files.ToList();
foreach (string file in files) {
string ext = Path.GetExtension(file).TrimStart('.').ToLower();
if (App.SubtitleTypes.Contains(ext)) {
mp.commandv("sub-add", file);
fileList.Remove(file);
}
}
if ((DateTime.Now - LastLoad).TotalMilliseconds < 500)
append = true;
if (fileList.Count == 0) return;
files = fileList.ToArray();
int count = mp.get_property_int("playlist-count");
LastLoad = DateTime.Now;
foreach (string file in files)
mp.commandv("loadfile", file, "append");
for (int i = 0; i < files.Length; i++)
if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower()))
commandv("sub-add", files[i]);
else
if (i == 0 && !append)
commandv("loadfile", files[i]);
else
commandv("loadfile", files[i], "append");
mp.set_property_int("playlist-pos", count);
for (int i = 0; i < count; i++)
mp.commandv("playlist-remove", "0");
mp.LoadFolder(files[0]);
if (string.IsNullOrEmpty(get_property_string("path")))
set_property_int("playlist-pos", 0);
if (loadFolder && !append) Task.Run(() => LoadFolder()); // user reported race condition
}
static void LoadFolder(string path)
public static void LoadFolder()
{
if (get_property_int("playlist-count") == 1)
{
if (!File.Exists(path)) return;
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
files = files.Where((file) => App.VideoTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower()) ||
App.AudioTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower())).ToList();
files.Sort(new StringLogicalComparer());
int index = files.IndexOf(path);
files.Remove(path);
foreach (string i in files)
commandv("loadfile", i, "append");
if (index > 0)
commandv("playlist-move", "0", (index + 1).ToString());
}
Thread.Sleep(200); // user reported race condition
string path = get_property_string("path");
if (!File.Exists(path) || get_property_int("playlist-count") != 1) return;
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
files = files.Where((file) =>
App.VideoTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower()) ||
App.AudioTypes.Contains(Path.GetExtension(file).TrimStart('.').ToLower())).ToList();
files.Sort(new StringLogicalComparer());
int index = files.IndexOf(path);
files.Remove(path);
foreach (string i in files)
commandv("loadfile", i, "append");
if (index > 0) commandv("playlist-move", "0", (index + 1).ToString());
}
static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)
@@ -622,16 +600,16 @@ namespace mpvnet
return rootPointer;
}
static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr pUnmanagedStringArray, int StringCount)
static string[] NativeUtf8StrArray2ManagedStrArray(IntPtr unmanagedStringArray, int StringCount)
{
IntPtr[] pIntPtrArray = new IntPtr[StringCount];
string[] ManagedStringArray = new string[StringCount];
Marshal.Copy(pUnmanagedStringArray, pIntPtrArray, 0, StringCount);
IntPtr[] intPtrArray = new IntPtr[StringCount];
string[] stringArray = new string[StringCount];
Marshal.Copy(unmanagedStringArray, intPtrArray, 0, StringCount);
for (int i = 0; i < StringCount; i++)
ManagedStringArray[i] = StringFromNativeUtf8(pIntPtrArray[i]);
stringArray[i] = StringFromNativeUtf8(intPtrArray[i]);
return ManagedStringArray;
return stringArray;
}
static string StringFromNativeUtf8(IntPtr nativeUtf8)
@@ -654,7 +632,7 @@ namespace mpvnet
if (File.Exists(LastHistoryPath) && totalMinutes > 1)
{
string historyFilepath = mp.ConfFolder + "history.txt";
string historyFilepath = ConfFolder + "history.txt";
File.AppendAllText(historyFilepath, DateTime.Now.ToString().Substring(0, 16) +
" " + totalMinutes.ToString().PadLeft(3) + " " +
@@ -670,50 +648,33 @@ namespace mpvnet
if (MainForm.Instance is null) return;
Rectangle cr = MainForm.Instance.ClientRectangle;
if (cr.Width == 0 || cr.Height == 0) return;
int len = cr.Height / 5;
using (Bitmap b = new Bitmap(cr.Width, cr.Height))
using (Bitmap b = new Bitmap(len, len))
{
using (Graphics g = Graphics.FromImage(b))
{
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.Clear(Color.Black);
int iconWidth = cr.Height / 7;
Rectangle r = new Rectangle(cr.Width / 2 - iconWidth / 2, cr.Height / 2 - iconWidth / 2, iconWidth, iconWidth);
g.DrawImage(Properties.Resources.mpvnet, r);
BitmapData bd = b.LockBits(cr, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
mp.commandv("overlay-add", "0", "0", "0", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
Rectangle rect = new Rectangle(0, 0, len, len);
g.DrawImage(Properties.Resources.mpvnet, rect);
BitmapData bd = b.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);
int x = Convert.ToInt32((cr.Width - len) / 2.0);
int y = Convert.ToInt32(((cr.Height - len) / 2.0) * 0.9);
commandv("overlay-add", "0", $"{x}", $"{y}", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
b.UnlockBits(bd);
IsLogoVisible = true;
}
}
}
public static void ProcessProperty(string name, string value)
{
switch (name)
{
case "autofit":
if (value.Length == 3 && value.EndsWith("%"))
if (int.TryParse(value.Substring(0, 2), out int result))
mp.Autofit = result / 100f;
break;
case "fs":
case "fullscreen":
mp.Fullscreen = value == "yes";
break;
case "screen":
mp.Screen = Convert.ToInt32(value);
break;
}
}
static void ReadMetaData()
{
lock (MediaTracks)
{
MediaTracks.Clear();
using (MediaInfo mi = new MediaInfo(mp.get_property_string("path")))
using (MediaInfo mi = new MediaInfo(get_property_string("path")))
{
int count = mi.GetCount(MediaInfoStreamKind.Video);