Compare commits

...

17 Commits
5.2.1 ... 5.4

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

View File

@@ -1,3 +1,27 @@
### 5.4
- added taskbar-progress implementation
- added new setting to start with maximized window
- long file paths work now even if not enabled by the OS
- fixed history being written even when history file wasn't created prior
- libmpv updated to shinchiro 2019-08-31
### 5.3
- added new feature: Open > Open DVD/Blu-ray Drive/Folder...
- the default of remember-volume has been set to yes
- scale, cscale, dscale defaults have been set to spline36,
profile=gpu-hq is not used in the defaults because it starts very slow
- new menu items have been added to navigate to the first and
last playlist position, key bindings: Home, End
- new config setting recent-count added, amount of menu items
shown under 'Open > Recent'
- in the config dialog the description for keep-open was corrected
because unlike mpv, mpv.net will never terminate automatically
- there was a rare occasion where the mpv.net logo wasn't shown
- fix excessive memory usage using `osd-scale-by-window = no`
- mpv setting osd-scale-by-window added to config dialog
### 5.2.1
- fixed race condition causing various features to fail

View File

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

View File

@@ -62,7 +62,7 @@ Table of contents
- Language agnostic JSON IPC to control the player with a external programs
- On Screen Controler (OSC, play control buttons)
- [Command Line Interface](https://mpv.io/manual/master/#options)
- If started from a PowerShell terminal mpv.net will attach to the terminal and print status and debug output
- If started from a PowerShell terminal mpv.net will attach to the terminal and print status and debug output ([Screenshot](#terminal-and-repl-screenshot))
- [OSD REPL](https://github.com/rossy/mpv-repl)
- DXVA2 video decoding acceleration
- 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
@@ -80,7 +80,7 @@ Table of contents
- Screenshot feature with many options
- File history feature to log time and filename
- A-B loop feature
- watch later feature to save the position
- Watch later feature to save the position
- [Manual](#manual)
### Screenshots

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 628 KiB

View File

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

View File

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

View File

@@ -40,7 +40,7 @@ namespace mpvnet
files.Add(App.ProcessInstance);
foreach (string arg in args)
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || File.Exists(arg)))
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") || arg.Contains(":\\") || arg.StartsWith("\\\\")))
files.Add(arg);
Process[] procs = Process.GetProcessesByName("mpvnet");

View File

@@ -27,6 +27,9 @@ namespace mpvnet
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int RegisterWindowMessage(string id);
[DllImport("user32.dll")]
public static extern bool AllowSetForegroundWindow(int dwProcessId);

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

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

View File

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

View File

@@ -1,17 +1,11 @@
# This file defines the input (keys and mouse) bindings of mpv and mpv.net
# and it also defines the context menu of mpv.net. mpv.net has an input
# editor and an config editor as alternative 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:
# This file defines the key and mouse bindings and the context menu
# of mpv.net. A input and config editor can be found in mpv.net's
# context menu under 'Settings'. 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:
# The defaults of mpv can be found at:
# https://github.com/mpv-player/mpv/blob/master/etc/input.conf
@@ -28,6 +22,7 @@
o script-message mpv.net open-files #menu: Open > Open Files...
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
_ script-message mpv.net open-optical-media #menu: Open > Open DVD/Blu-ray Drive/Folder...
_ 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...
@@ -46,6 +41,9 @@
F11 playlist-prev #menu: Navigate > Previous File
F12 playlist-next #menu: Navigate > Next File
_ ignore #menu: Navigate > -
Home set playlist-pos 0 #menu: Navigate > First File
End script-message mpv.net playlist-last #menu: Navigate > Last File
_ ignore #menu: Navigate > -
PGUP add chapter 1 #menu: Navigate > Next Chapter
PGDWN add chapter -1 #menu: Navigate > Previous Chapter
_ ignore #menu: Navigate > -
@@ -199,4 +197,3 @@
Ctrl+Wheel_Down no-osd seek -7
MBTN_Left_DBL cycle fullscreen
KP_Enter cycle fullscreen
MBTN_Left ignore

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="About mpv.net" Height="230" Width="500" FontSize="16" ShowInTaskbar="False"
Title="About mpv.net" Height="230" Width="400" FontSize="16" ShowInTaskbar="False"
WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">

View File

@@ -1,7 +1,6 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace mpvnet
{
@@ -10,7 +9,7 @@ namespace mpvnet
public AboutWindow()
{
InitializeComponent();
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion}";
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})";
mpvVersion.Text = $"{mp.get_property_string("mpv-version")} ({File.GetLastWriteTime(PathHelp.StartupPath + "mpv-1.dll").ToShortDateString()})";
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -61,12 +61,12 @@ namespace mpvnet
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
public static IntPtr Handle { get; set; }
public static IntPtr WindowHandle { get; set; }
public static Extension Extension { get; set; }
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
public static Size VideoSize { get; set; }
public static TimeSpan Duration;
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
@@ -81,6 +81,7 @@ namespace mpvnet
public static bool IsQuitNeeded { set; get; } = true;
public static bool Fullscreen { get; set; }
public static bool Border { get; set; } = true;
public static bool TaskbarProgress { get; set; } = true;
public static int Screen { get; set; } = -1;
public static int Edition { get; set; }
@@ -93,7 +94,7 @@ namespace mpvnet
{
LoadLibrary("mpv-1.dll");
Handle = mpv_create();
Task.Run(() => { EventLoop(); });
Task.Run(() => EventLoop());
if (App.IsStartedFromTerminal)
{
@@ -104,8 +105,8 @@ namespace mpvnet
set_property_string("wid", MainForm.Hwnd.ToString());
set_property_string("osc", "yes");
set_property_string("force-window", "yes");
set_property_string("input-media-keys", "yes");
set_property_string("force-window", "yes");
set_property_string("config-dir", ConfigFolder);
set_property_string("config", "yes");
@@ -113,7 +114,6 @@ namespace mpvnet
mpv_initialize(Handle);
Initialized?.Invoke();
LoadMpvScripts();
if (GPUAPI != "vulkan") ProcessCommandLine(false);
}
public static void ProcessProperty(string name, string value)
@@ -137,6 +137,7 @@ namespace mpvnet
case "fs":
case "fullscreen": Fullscreen = value == "yes"; break;
case "border": Border = value == "yes"; break;
case "taskbar-progress": TaskbarProgress = value == "yes"; break;
case "screen": Screen = Convert.ToInt32(value); break;
case "gpu-api": GPUAPI = value; break;
}
@@ -318,7 +319,7 @@ namespace mpvnet
break;
case mpv_event_id.MPV_EVENT_FILE_LOADED:
HideLogo();
FileLoaded?.Invoke();
Duration = TimeSpan.FromSeconds(get_property_number("duration"));
Size vidSize = new Size(get_property_int("width"), get_property_int("height"));
if (vidSize.Width == 0 || vidSize.Height == 0)
vidSize = new Size(1, 1);
@@ -330,6 +331,7 @@ namespace mpvnet
VideoSizeAutoResetEvent.Set();
Task.Run(new Action(() => ReadMetaData()));
WriteHistory(get_property_string("path"));
FileLoaded?.Invoke();
break;
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
TracksChanged?.Invoke();
@@ -339,7 +341,7 @@ namespace mpvnet
break;
case mpv_event_id.MPV_EVENT_IDLE:
Idle?.Invoke();
if (get_property_int("playlist-count") == 0) ShowLogo();
ShowLogo();
break;
case mpv_event_id.MPV_EVENT_PAUSE:
Pause?.Invoke();
@@ -377,16 +379,19 @@ namespace mpvnet
var propData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property));
if (propData.format == mpv_format.MPV_FORMAT_FLAG)
lock (BoolPropChangeActions)
foreach (var i in BoolPropChangeActions)
if (i.Key== propData.name)
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data) == 1);
if (propData.format == mpv_format.MPV_FORMAT_STRING)
lock (StringPropChangeActions)
foreach (var i in StringPropChangeActions)
if (i.Key == propData.name)
i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure<IntPtr>(propData.data)));
if (propData.format == mpv_format.MPV_FORMAT_INT64)
lock (IntPropChangeActions)
foreach (var i in IntPropChangeActions)
if (i.Key == propData.name)
i.Value.Invoke(Marshal.PtrToStructure<int>(propData.data));
@@ -414,12 +419,9 @@ namespace mpvnet
static void HideLogo()
{
if (IsLogoVisible)
{
commandv("overlay-remove", "0");
command("overlay-remove 0");
IsLogoVisible = false;
}
}
static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
@@ -548,6 +550,7 @@ namespace mpvnet
if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}");
else
lock (IntPropChangeActions)
IntPropChangeActions.Add(new KeyValuePair<string, Action<int>>(name, action));
}
@@ -558,6 +561,7 @@ namespace mpvnet
if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}");
else
lock (BoolPropChangeActions)
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action));
}
@@ -568,6 +572,7 @@ namespace mpvnet
if (err < 0)
throw new Exception($"{name}: {(mpv_error)err}");
else
lock (StringPropChangeActions)
StringPropChangeActions.Add(new KeyValuePair<string, Action<string>>(name, action));
}
@@ -620,7 +625,8 @@ namespace mpvnet
foreach (string i in args)
{
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") || File.Exists(i)))
if (!i.StartsWith("--") && (i == "-" || i.Contains("://") ||
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
{
files.Add(i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
@@ -631,8 +637,8 @@ namespace mpvnet
if (files.Count == 0 || files[0].Contains("://"))
{
VideoSizeAutoResetEvent.Set();
VideoSizeChanged?.Invoke();
VideoSizeAutoResetEvent.Set();
}
}
}
@@ -671,7 +677,7 @@ namespace mpvnet
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) =>
files = files.Where(file =>
App.VideoTypes.Contains(file.ShortExt()) ||
App.AudioTypes.Contains(file.ShortExt()) ||
App.ImageTypes.Contains(file.ShortExt())).ToList();
@@ -729,14 +735,12 @@ namespace mpvnet
static void WriteHistory(string path)
{
if (!File.Exists(path)) return;
if (!File.Exists(ConfigFolder + "history.txt") || !File.Exists(path)) return;
int totalMinutes = Convert.ToInt32((DateTime.Now - LastHistoryStartDateTime).TotalMinutes);
if (File.Exists(LastHistoryPath) && totalMinutes > 1)
{
File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) +
" " + totalMinutes.ToString().PadLeft(3) + " " + Path.GetFileNameWithoutExtension(LastHistoryPath) + "\r\n");
}
LastHistoryPath = path;
LastHistoryStartDateTime = DateTime.Now;