From 1270dd474e29b68d370b549e326e7565a7aad264 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Wed, 22 Apr 2020 08:04:26 +0200 Subject: [PATCH] 5.4.4.4 Beta --- Changelog.md | 13 +++++-- README.md | 23 ++++++++----- mpv.net/Properties/AssemblyInfo.cs | 4 +-- mpv.net/WinForms/MainForm.cs | 6 ++-- mpv.net/mpv/mp.cs | 27 ++++++++++----- scripts/examples/pause-when-minimize.cs | 43 ++++++++++++++++++++++++ scripts/examples/pause-when-minimize.lua | 6 ++++ 7 files changed, 97 insertions(+), 25 deletions(-) create mode 100644 scripts/examples/pause-when-minimize.cs diff --git a/Changelog.md b/Changelog.md index 870c5e1..1eb8c6a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,11 +1,18 @@ -5.4.4.4 Beta (not yet released) +5.4.4.5 Beta (not yet released) ============ -- with `border=no` the OSC top bar window buttons min, max and close are supported. +- + +5.4.4.4 Beta +============ + +- with `border=no` the OSC top bar window buttons min, max and close are fully supported. - anamorphic videos are shown without black bars, the window is resized according to the ascpect ratio. - PowerShell 5.1 was made optional. -- full implementation for `window-minimized` and `window-maximized` +- full implementation for `window-minimized` and `window-maximized`, + scripts that depend on this like pause-when-minimize.lua are now fully supported. +- fix cycling from maximized to fullscreen and back. 5.4.4.3 Beta diff --git a/README.md b/README.md index 928322d..5f382b5 100644 --- a/README.md +++ b/README.md @@ -8,30 +8,37 @@ mpv.net is a modern media player for Windows that works just like [mpv](https://mpv.io). + #### Graphical User Interface Modern GUI that supports customizable color themes. + #### Command Line Interface -mpv.net has the [CLI of mpv](https://mpv.io/manual/master/#options). +mpv.net supports mpvs property based [command line switches](https://mpv.io/manual/master/#options). + #### High quality video output -libmpv has an OpenGL based video output that is capable of many features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more. +libmpv has an video output that is capable of many features loved by videophiles, such as video scaling with popular high quality algorithms, color management, frame timing, interpolation, HDR, and more. + #### On Screen Controller The OSC of libmpv offers play controls with a modern flat design. ([Screenshot](#main-window-screenshot)) + #### GPU video decoding libmpv leverages the FFmpeg hwaccel APIs to support DXVA2 video decoding acceleration. + #### Active development mpv.net is under active development. Want a feature? Post a [patch](https://github.com/stax76/mpv.net/pulls) or [request it](https://github.com/stax76/mpv.net/issues)! + #### Based on libmpv mpv.net is based on libmpv which offers a straightforward C API that was designed from the ground up to make mpv usable as a library and facilitate easy integration into other applications. mpv is like vlc not based on DirectShow or Media Foundation. @@ -57,17 +64,17 @@ Table of contents Features -------- +- Open source - High degree of mpv compatibility, almost all mpv features are available -- Great usability due to everything in the application being searchable -- Open source built with modern tools - Customizable context menu defined in the same file as the key bindings ([Screenshot](#context-menu-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt)) -- Searchable config dialog ([Screenshot](#config-editor-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt)) -- Searchable input (key/mouse) binding editor ([Screenshot](#input-editor-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt)) +- Config (settings) dialog ([Screenshot](#config-editor-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt)) +- Input (key/mouse) binding editor ([Screenshot](#input-editor-screenshot), [Defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt)) +- Many features like the config editor and shortcut key editor are fully searchable - Configuration files that are easy to read and edit ([Manual](https://mpv.io/manual/master/#configuration-files)) - Searchable command palette to quickly find commands and keys ([Screenshot](#command-palette-screenshot)) - Modern graphical user interface with customizable color themes ([Screenshot](#config-editor-screenshot)) - Extension API for .NET languages (C#, VB.NET and F#) -- Scripting API for Python, C#, Lua, JavaScript and PowerShell ([Wiki](https://github.com/stax76/mpv.net/wiki/Scripting)) +- Scripting API for C#, Lua, JavaScript and PowerShell ([Wiki](https://github.com/stax76/mpv.net/wiki/Scripting)) - Language agnostic JSON IPC to control the player with a external programs - On Screen Controler (OSC, play control buttons) ([Screenshot](#main-window-screenshot)) - [Command Line Interface](https://mpv.io/manual/master/#options) @@ -244,7 +251,7 @@ Before making a support request for a particular issue, please try if it was alr [Issue tracker](https://github.com/stax76/mpv.net/issues), feel free to use for anything mpv(.net) related. -You can support the development of mpv.net with a PayPal donation: +You can support my work with a PayPal donation. The input hardware support in mpv.net is not 100% mpv compatible, people use all kind of weird input hardware and sometimes I have to buy those to support them. diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 61829a3..f2ff25a 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -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("5.4.4.3")] -[assembly: AssemblyFileVersion("5.4.4.3")] +[assembly: AssemblyVersion("5.4.4.4")] +[assembly: AssemblyFileVersion("5.4.4.4")] diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index c42e660..006c292 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -99,6 +99,9 @@ namespace mpvnet Left = target.X + (target.Width - Width) / 2; Top = target.Y + (target.Height - Height) / 2; + if (!mp.Border) + FormBorderStyle = FormBorderStyle.None; + int posX = RegistryHelp.GetInt(App.RegPath, "PosX"); int posY = RegistryHelp.GetInt(App.RegPath, "PosY"); @@ -119,9 +122,6 @@ namespace mpvnet SetFormPosAndSize(1, true); WindowState = FormWindowState.Minimized; } - - if (!mp.Border) - FormBorderStyle = FormBorderStyle.None; } catch (Exception ex) { diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index c94b978..3b206aa 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -572,6 +572,24 @@ namespace mpvnet HandleError(err, throwException, "error executing command:", command); } + public static void set_property_int(string name, int value, bool throwException = false) + { + Int64 val = value; + mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val); + + if (err < 0) + HandleError(err, throwException, $"error setting property: {name} = {value}"); + } + + public static void set_property_bool(string name, bool value, bool throwException = false) + { + Int64 val = (value) ? 1 : 0; + mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, ref val); + + if (err < 0) + HandleError(err, throwException, $"error setting property: {name} = {value}"); + } + public static void set_property_string(string name, string value, bool throwException = false) { byte[] bytes = GetUtf8Bytes(value); @@ -630,15 +648,6 @@ namespace mpvnet return value; } - public static void set_property_int(string name, int value, bool throwException = false) - { - Int64 val = value; - mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val); - - if (err < 0) - HandleError(err, throwException, $"error setting property: {name} = {value}"); - } - public static void observe_property_int(string name, Action action) { mpv_error err = mpv_observe_property(Handle, (ulong)action.GetHashCode(), diff --git a/scripts/examples/pause-when-minimize.cs b/scripts/examples/pause-when-minimize.cs new file mode 100644 index 0000000..b217944 --- /dev/null +++ b/scripts/examples/pause-when-minimize.cs @@ -0,0 +1,43 @@ + +// Pauses playback when window is minimized and resumes afterwards. + +using System; +using System.Windows.Forms; + +using mpvnet; + +class Script +{ + MainForm Form; + + bool WasPlaying; + bool WasPaused; + + public Script() + { + Form = MainForm.Instance; + Form.Resize += Form_Resize; + } + + private void Form_Resize(object sender, EventArgs e) + { + if (Form.WindowState == FormWindowState.Minimized) + { + WasPlaying = !mp.get_property_bool("pause"); + + if (WasPlaying) + { + mp.set_property_bool("pause", true, true); + WasPaused = true; + } + } + else + { + if (WasPaused) + { + mp.set_property_bool("pause", false, true); + WasPaused = false; + } + } + } +} diff --git a/scripts/examples/pause-when-minimize.lua b/scripts/examples/pause-when-minimize.lua index cda6b46..f36fc61 100644 --- a/scripts/examples/pause-when-minimize.lua +++ b/scripts/examples/pause-when-minimize.lua @@ -1,4 +1,10 @@ +-- https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/pause-when-minimize.lua + +-- This script pauses playback when minimizing the window, and resumes playback +-- if it's brought back again. If the player was already paused when minimizing, +-- then try not to mess with the pause state. + local did_minimize = false mp.observe_property("window-minimized", "bool", function(name, value)