This commit is contained in:
Frank Skare
2020-12-13 08:12:50 +01:00
parent 235a52a701
commit 4d985c7b7c
15 changed files with 191 additions and 161 deletions

View File

@@ -2,6 +2,17 @@
5.4.8.6 Beta (not yet released)
============
- Improved OSD message when cycling audio.
- Finally support DVD audio and subtitle track selection.
- Profiles can be shown on the command line with --profile=help
- Decoders can be shown on the command line with --ad=help and --vd=help
- Decoders can be shown in the menu under: View > Show Decoders
- Demuxers can be shown in the menu under: View > Show Demuxers
- Audio devices can be shown in the menu under: View > Show Audio Devices
- Audio devices can be shown on the command line with --audio-device=help
- Protocols can be shown in the menu under: View > Show Protocols
5.4.8.5 Beta
============

View File

@@ -20,86 +20,7 @@ Table of contents
* [Hidden Features](#hidden-features)
* [Differences](#differences)
* [Technical Overview](#technical-overview)
* [Context Menu](#context-menu)
+ [Open > Open Files](#open--open-files)
+ [Open > Open URL or file path from clipboard](#open--open-url-or-file-path-from-clipboard)
+ [Open > Open DVD/Blu-ray Drive/Folder](#open--open-dvd-blu-ray-drive-folder)
+ [Open > Show media search](#open--show-media-search)
+ [Open > Load external audio files](#open--load-external-audio-files)
+ [Open > Load external subtitle files](#open--load-external-subtitle-files)
+ [Play/Pause](#play-pause)
+ [Stop](#stop)
+ [Toggle Fullscreen](#toggle-fullscreen)
+ [Navigate > Previous File](#navigate--previous-file)
+ [Navigate > Next File](#navigate--next-file)
+ [Navigate > Next Chapter](#navigate--next-chapter)
+ [Navigate > Previous Chapter](#navigate--previous-chapter)
+ [Navigate > Jump Next Frame](#navigate--jump-next-frame)
+ [Navigate > Jump Previous Frame](#navigate--jump-previous-frame)
+ [Navigate > Jump](#navigate--jump)
+ [Pan & Scan > Increase Size](#pan--scan--increase-size)
+ [Pan & Scan > Decrease Size](#pan--scan--decrease-size)
+ [Pan & Scan > Move Left](#pan--scan--move-left)
+ [Pan & Scan > Move Right](#pan--scan--move-right)
+ [Pan & Scan > Move Up](#pan--scan--move-up)
+ [Pan & Scan > Move Down](#pan--scan--move-down)
+ [Pan & Scan > Decrease Height](#pan--scan--decrease-height)
+ [Pan & Scan > Increase Height](#pan--scan--increase-height)
+ [Pan & Scan > Reset](#pan--scan--reset)
+ [Video > Decrease Contrast](#video--decrease-contrast)
+ [Video > Increase Contrast](#video--increase-contrast)
+ [Video > Decrease Brightness](#video--decrease-brightness)
+ [Video > Increase Brightness](#video--increase-brightness)
+ [Video > Decrease Gamma](#video--decrease-gamma)
+ [Video > Increase Gamma](#video--increase-gamma)
+ [Video > Decrease Saturation](#video--decrease-saturation)
+ [Video > Increase Saturation](#video--increase-saturation)
+ [Video > Take Screenshot](#video--take-screenshot)
+ [Video > Toggle Deinterlace](#video--toggle-deinterlace)
+ [Video > Cycle Aspect Ratio](#video--cycle-aspect-ratio)
+ [Audio > Cycle/Next](#audio--cycle-next)
+ [Audio > Delay +0.1](#audio--delay--01)
+ [Audio > Delay -0.1](#audio--delay--01)
+ [Subtitle > Cycle/Next](#subtitle--cycle-next)
+ [Subtitle > Toggle Visibility](#subtitle--toggle-visibility)
+ [Subtitle > Delay -0.1](#subtitle--delay--01)
+ [Subtitle > Delay 0.1](#subtitle--delay-01)
+ [Subtitle > Move Up](#subtitle--move-up)
+ [Subtitle > Move Down](#subtitle--move-down)
+ [Subtitle > Decrease Subtitle Font Size](#subtitle--decrease-subtitle-font-size)
+ [Subtitle > Increase Subtitle Font Size](#subtitle--increase-subtitle-font-size)
+ [Volume > Up](#volume--up)
+ [Volume > Down](#volume--down)
+ [Volume > Mute](#volume--mute)
+ [Speed > -10%](#speed---10-)
+ [Speed > 10%](#speed--10-)
+ [Speed > Half](#speed--half)
+ [Speed > Double](#speed--double)
+ [Speed > Reset](#speed--reset)
+ [Extensions > Rating > 0stars](#extensions--rating--0stars)
+ [View > On Top > Enable](#view--on-top--enable)
+ [View > On Top > Disable](#view--on-top--disable)
+ [View > File Info](#view--file-info)
+ [View > Show Statistics](#view--show-statistics)
+ [View > Toggle Statistics](#view--toggle-statistics)
+ [View > Toggle OSC Visibility](#view--toggle-osc-visibility)
+ [View > Show Playlist](#view--show-playlist)
+ [View > Show Audio/Video/Subtitle List](#view--show-audio-video-subtitle-list)
+ [Settings > Show Config Editor](#settings--show-config-editor)
+ [Settings > Show Input Editor](#settings--show-input-editor)
+ [Settings > Open Config Folder](#settings--open-config-folder)
+ [Tools > Command Palette](#tools--command-palette)
+ [Tools > Show History](#tools--show-history)
+ [Tools > Set/clear A-B loop points](#tools--set-clear-a-b-loop-points)
+ [Tools > Toggle infinite file looping](#tools--toggle-infinite-file-looping)
+ [Tools > Toggle Hardware Decoding](#tools--toggle-hardware-decoding)
+ [Tools > Setup](#tools--setup)
+ [Help > Show mpv manual](#help--show-mpv-manual)
+ [Help > Show mpv.net manual](#help--show-mpvnet-manual)
+ [Help > Check for Updates](#help--check-for-updates)
+ [Help > About mpv.net](#help--about-mpvnet)
+ [Exit](#exit)
+ [Exit Watch Later](#exit-watch-later)
* [Context Menu Commands](#context-menu)
About
@@ -517,6 +438,8 @@ Whenever the control key is pressed when files or URLs are opened, the playlist
Pressing the shift key while opening a single file will suppress loading all files in the folder.
Blu-ray and DVD ISO image files are supported.
### Open > Open URL or file path from clipboard

View File

@@ -1,4 +1,5 @@

using mpvnet;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -147,7 +148,7 @@ namespace DynamicGUI
{
void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(e.Uri.AbsoluteUri);
ProcessHelp.ShellExecute(e.Uri.AbsoluteUri);
}
public void SetURL(string url)

View File

@@ -37,16 +37,20 @@ 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 "open-conf-folder": Process.Start(core.ConfigFolder); break;
case "shell-execute": Process.Start(args[0]); break;
case "open-conf-folder": ProcessHelp.ShellExecute(core.ConfigFolder); break;
case "shell-execute": ProcessHelp.ShellExecute(args[0]); break;
case "show-info": ShowInfo(); break;
case "playlist-first": PlaylistFirst(); break;
case "playlist-last": PlaylistLast(); break;
case "show-profiles": ShowProfiles(); break;
case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break;
case "show-properties": ShowProperties(); break;
case "show-commands": ShowCommands(); break;
case "show-keys": ShowKeys(); break;
case "show-keys": ShowTextWithEditor("input-key-list", core.get_property_string("input-key-list").Replace(",", BR)); break;
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
case "show-audio-devices": ShowTextWithEditor("audio-device-list", core.get_property_osd_string("audio-device-list")); break;
case "show-decoders": ShowTextWithEditor("decoder-list", mpvHelp.GetDecoders()); break;
case "show-protocols": ShowTextWithEditor("protocol-list", mpvHelp.GetProtocols()); break;
case "show-demuxers": ShowTextWithEditor("demuxer-lavf-list", mpvHelp.GetDemuxers()); break;
default: Msg.ShowError($"No command '{id}' found."); break;
}
}
@@ -128,7 +132,7 @@ namespace mpvnet
public static void ShowHistory()
{
if (File.Exists(core.ConfigFolder + "history.txt"))
Process.Start(core.ConfigFolder + "history.txt");
ProcessHelp.ShellExecute(core.ConfigFolder + "history.txt");
else
{
if (Msg.ShowQuestion("Create history.txt file in config folder?",
@@ -288,49 +292,18 @@ namespace mpvnet
public static void CycleAudio()
{
MediaTrack[] audTracks = core.MediaTracks.Where(track => track.Type == "a").ToArray();
MediaTrack[] tracks = core.MediaTracks.Where(track => track.Type == "a").ToArray();
if (audTracks.Length < 2)
if (tracks.Length < 2)
return;
int aid = core.get_property_int("aid");
aid += 1;
if (aid > audTracks.Length)
if (++aid > tracks.Length)
aid = 1;
core.commandv("set", "aid", aid.ToString());
core.commandv("show-text", audTracks[aid - 1].Text.Substring(3), "5000");
}
static void ShowProfiles()
{
string code = @"
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
{
$item.name
''
foreach ($option in $item.options)
{
' ' + $option.key + ' = ' + $option.value
}
''
}";
string json = core.get_property_string("profile-list");
string file = Path.GetTempPath() + @"\mpv profile-list.txt";
File.WriteAllText(file, BR + PowerShell.InvokeAndReturnString(code, "json", json));
Process.Start(file);
}
static void ShowKeys()
{
string txt = core.get_property_string("input-key-list");
string file = Path.GetTempPath() + @"\mpv input-key-list.txt";
File.WriteAllText(file, txt.Replace(",", BR) + BR);
Process.Start(file);
core.commandv("show-text", aid + ": " + tracks[aid - 1].Text.Substring(3), "5000");
}
static void ShowCommands()
@@ -355,17 +328,21 @@ namespace mpvnet
}";
string json = core.get_property_string("command-list");
string file = Path.GetTempPath() + @"\mpv command-list.txt";
File.WriteAllText(file, PowerShell.InvokeAndReturnString(code, "json", json) + BR);
Process.Start(file);
ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json));
}
static void ShowProperties()
{
string file = Path.GetTempPath() + @"\mpv property-list.txt";
var props = core.get_property_string("property-list").Split(',').OrderBy(prop => prop);
File.WriteAllText(file, BR + string.Join(BR, props) + BR);
Process.Start(file);
ShowTextWithEditor("property-list", string.Join(BR, props));
}
static void ShowTextWithEditor(string name, string text)
{
string file = Path.GetTempPath() + $"\\{name}.txt";
//UTF8 without BOM
File.WriteAllText(file, BR + text.Trim() + BR);
ProcessHelp.ShellExecute(file);
}
}
}

View File

@@ -28,6 +28,14 @@ public static class Extensions
return "";
}
public static string ToLowerEx(this string instance)
{
if (instance != null)
return instance.ToLower();
return "";
}
public static string FileName(this string instance)
{
if (string.IsNullOrEmpty(instance))

View File

@@ -2,8 +2,12 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using static mpvnet.Core;
using static NewLine;
namespace mpvnet
{
public static class ProcessHelp
@@ -138,5 +142,49 @@ namespace mpvnet
return null;
}
public static string GetProfiles()
{
string code = @"
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
{
$item.name
''
foreach ($option in $item.options)
{
' ' + $option.key + ' = ' + $option.value
}
''
}";
string json = core.get_property_string("profile-list");
return PowerShell.InvokeAndReturnString(code, "json", json).Trim();
}
public static string GetDecoders()
{
string code = @"
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort codec))
{
$item.codec + ' - ' + $item.description
}";
string json = core.get_property_string("decoder-list");
return PowerShell.InvokeAndReturnString(code, "json", json).Trim();
}
public static string GetProtocols()
{
string list = core.get_property_string("protocol-list");
return string.Join(BR, list.Split(',').OrderBy(a => a));
}
public static string GetDemuxers()
{
string list = core.get_property_string("demuxer-lavf-list");
return string.Join(BR, list.Split(',').OrderBy(a => a));
}
}
}

View File

@@ -204,6 +204,14 @@ options = [{ name = "no", help = "Don't automatically load external audio fil
{ name = "fuzzy", help = "Load all audio files containing media filename." },
{ name = "all", help = "Load all audio files in the current and audio-file-paths directories." }]
[[settings]]
name = "audio-device"
file = "mpv"
filter = "Audio"
type = "string"
url = "https://mpv.io/manual/master/#options-audio-device"
help = "<name> Use the given audio device. This consists of the audio output name, e.g. alsa, followed by /, followed by the audio output specific device name. The default value for this option is auto, which tries every audio output in preference order with the default device.\nAvailable devices can be found in the mpv.net context menu under:\nView > Show Audio Devices"
[[settings]]
name = "slang"
file = "mpv"

View File

@@ -1,19 +1,18 @@
# This file defines the key and mouse bindings and the context menu of mpv.net.
# A convenient input and config editor can be found in the context menu of mpv.net
# under 'Settings'.
# A input and config editor can be found in the context menu under 'Settings'.
# The mpv.conf defaults of mpv.net contain: 'input-default-bindings = no'
# which disables the input defaults of mpv. 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 do a text search on ' o '.
# which disables the input defaults of mpv.
# Every line in this file begins with a space character to make search easier,
# if you want to know if 'o' has already a binding you can search for ' o '.
# input test mode:
# mpvnet --input-test
# input key list:
# mpv --input-keylist
# The input key list can be found in the context menu under: View > Show Keys
# mpv.net input.conf defaults:
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt
@@ -149,14 +148,18 @@
t script-binding stats/display-stats #menu: View > Show Statistics
T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics
Del script-binding osc/visibility #menu: View > Toggle OSC Visibility
F8 script-binding show-playlist #menu: View > Show Playlist
F9 show-text ${track-list} 5000 #menu: View > Show Tracks
p show-progress #menu: View > Show Progress
Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles
Shift+p script-message mpv.net show-properties #menu: View > Show Properties
_ script-message mpv.net show-audio-devices #menu: View > Show Audio Devices
Shift+c script-message mpv.net show-commands #menu: View > Show Commands
_ script-message mpv.net show-keys #menu: View > Show Keys
` script-binding console/enable #menu: View > Show Console
_ script-message mpv.net show-decoders #menu: View > Show Decoders
_ script-message mpv.net show-demuxers #menu: View > Show Demuxers
_ script-message mpv.net show-keys #menu: View > Show Keys
F8 script-binding show-playlist #menu: View > Show Playlist
Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles
p show-progress #menu: View > Show Progress
Shift+p script-message mpv.net show-properties #menu: View > Show Properties
_ script-message mpv.net show-protocols #menu: View > Show Protocols
F9 show-text ${track-list} 5000 #menu: View > Show Tracks
c script-message mpv.net show-conf-editor #menu: Settings > Show Config Editor
Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor

View File

@@ -19,10 +19,7 @@
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock>
<TextBlock HorizontalAlignment="Center">Copyright (C) 2017-2020 Frank Skare (stax76)</TextBlock>
<TextBlock Name="Version" HorizontalAlignment="Center" />
<TextBlock Name="mpvVersion" HorizontalAlignment="Center" />
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20">MIT License</TextBlock>
<TextBlock Name="ContentBlock" TextAlignment="Center"></TextBlock>
</StackPanel>
</Grid>
</Window>

View File

@@ -12,8 +12,9 @@ namespace mpvnet
public AboutWindow()
{
InitializeComponent();
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})";
mpvVersion.Text = $"{core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})";
ContentBlock.Text= "Copyright (C) 2017-2020 Frank Skare (stax76)\n" +
$"mpv.net {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})\n" +
$"{core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {core.get_property_string("ffmpeg-version")}\nMIT License";
}
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();

View File

@@ -84,9 +84,8 @@ namespace mpvnet
case Key.Down:
{
int index = ListView.SelectedIndex;
index += 1;
if (index > ListView.Items.Count - 1)
if (++index > ListView.Items.Count - 1)
index = ListView.Items.Count - 1;
ListView.SelectedIndex = index;

View File

@@ -294,7 +294,7 @@ namespace mpvnet
void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
{
Process.Start(Path.GetDirectoryName(core.ConfPath));
ProcessHelp.ShellExecute(Path.GetDirectoryName(core.ConfPath));
}
void PreviewTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
@@ -304,12 +304,12 @@ namespace mpvnet
void ShowManualTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
{
Process.Start("https://mpv.io/manual/master/");
ProcessHelp.ShellExecute("https://mpv.io/manual/master/");
}
void SupportTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
{
Process.Start("https://github.com/stax76/mpv.net#Support");
ProcessHelp.ShellExecute("https://github.com/stax76/mpv.net#Support");
}
protected override void OnKeyDown(KeyEventArgs e)

View File

@@ -73,8 +73,10 @@ namespace mpvnet
case Key.Up:
{
int index = ListView.SelectedIndex;
index -= 1;
if (index < 0) index = 0;
if (--index < 0)
index = 0;
ListView.SelectedIndex = index;
ListView.ScrollIntoView(ListView.SelectedItem);
}
@@ -82,8 +84,10 @@ namespace mpvnet
case Key.Down:
{
int index = ListView.SelectedIndex;
index += 1;
if (index > ListView.Items.Count - 1) index = ListView.Items.Count - 1;
if (++index > ListView.Items.Count - 1)
index = ListView.Items.Count - 1;
ListView.SelectedIndex = index;
ListView.ScrollIntoView(ListView.SelectedItem);
}

View File

@@ -357,9 +357,10 @@ public struct HSLColor
static double MoveIntoRange(double temp3)
{
if (temp3 < 0)
temp3 += 1;
temp3++;
else if (temp3 > 1)
temp3 -= 1;
temp3--;
return temp3;
}

View File

@@ -800,6 +800,22 @@ namespace mpvnet
HandleError(err, throwException, $"error setting property: {name} = " + value);
}
public string get_property_osd_string(string name, bool throwException = false)
{
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
mpv_format.MPV_FORMAT_OSD_STRING, out IntPtr lpBuffer);
if (err == 0)
{
string ret = ConvertFromUtf8(lpBuffer);
mpv_free(lpBuffer);
return ret;
}
HandleError(err, throwException, $"error getting property: {name}");
return "";
}
public string get_opt(string name, string defaultValue = "")
{
string value = get_property_string("script-opts");
@@ -918,6 +934,18 @@ namespace mpvnet
}
}
public void show_text(string text, int duration = 0, int fontSize = 0)
{
if (duration == 0)
duration = get_property_int("osd-duration");
if (fontSize == 0)
fontSize = get_property_int("osd-font-size");
core.command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize +
"}${osd-ass-cc/1}" + text + "\" " + duration);
}
public void HandleError(mpv_error err, bool throwException, params string[] messages)
{
if (throwException)
@@ -946,6 +974,27 @@ namespace mpvnet
{
try
{
if (arg == "--profile=help")
{
ConsoleHelp.Write(mpvHelp.GetProfiles(), null);
continue;
}
else if (arg == "--vd=help" || arg == "--ad=help")
{
ConsoleHelp.Write(mpvHelp.GetDecoders(), null);
continue;
}
else if (arg == "--audio-device=help")
{
ConsoleHelp.Write(core.get_property_osd_string("audio-device-list"), null);
continue;
}
else if (arg == "--input-keylist")
{
ConsoleHelp.Write(core.get_property_string("input-key-list").Replace(",", BR), null);
continue;
}
if (!arg.StartsWith("--"))
arg = "-" + arg;
@@ -1074,7 +1123,7 @@ namespace mpvnet
{
using (TaskDialog<string> td = new TaskDialog<string>())
{
td.MainInstruction = "Blu-ray or DVD?";
td.MainInstruction = "Is this a Blu-ray or a DVD image?";
td.AddCommand("Blu-ray");
td.AddCommand("DVD");
@@ -1210,7 +1259,7 @@ namespace mpvnet
{
string path = get_property_string("path");
if (!path.StartsWithEx("bd://"))
if (!path.ToLowerEx().StartsWithEx("bd://"))
lock (BluRayTitles)
BluRayTitles.Clear();
@@ -1218,7 +1267,7 @@ namespace mpvnet
{
MediaTracks.Clear();
if (path.StartsWithEx("bd://"))
if (path.ToLowerEx().StartsWithEx("bd://") || path.ToLowerEx().StartsWithEx("dvd://"))
{
int count = core.get_property_int("track-list/count");