New options autofit-image and autofit-audio

This commit is contained in:
stax76
2022-06-08 10:16:40 +02:00
parent 2257af6294
commit 6337818dbc
7 changed files with 77 additions and 16 deletions

View File

@@ -1,4 +1,9 @@
- New options `autofit-image` and `autofit-audio`, like
autofit but used for image and audio files. Default 80.
- Fix long commands causing key bindings not visible in the
command palette.
# 6.0.0.0 Beta (2022-06-05) # 6.0.0.0 Beta (2022-06-05)
- The options `cache` and `demuxer-max-bytes`have been added - The options `cache` and `demuxer-max-bytes`have been added

View File

@@ -282,6 +282,9 @@ Registers the file associations.
### scale-window \<factor\> ### scale-window \<factor\>
Decreases or increases the Window size. Decreases or increases the Window size.
### select-profile
Shows the command palette to select a profile.
### shell-execute \<file|URL\> ### shell-execute \<file|URL\>
Shell executes a single file or URL. Shell executes a single file or URL.
@@ -381,6 +384,12 @@ mpv.net specific options can be found in the conf editor searching for 'mpv.net'
The options are saved in the mpvnet.conf file. The options are saved in the mpvnet.conf file.
#### --autofit-audio \<integer\>
Initial window height in percent for audio files. Default: 80
#### --autofit-image \<integer\>
Initial window height in percent for image files. Default: 80
#### --queue \<files\> #### --queue \<files\>
Adds files to the playlist, requires [--process-instance=single](#--process-instancevalue). Adds files to the playlist, requires [--process-instance=single](#--process-instancevalue).

View File

@@ -36,6 +36,8 @@ namespace mpvnet
public static int StartThreshold { get; set; } = 1500; public static int StartThreshold { get; set; } = 1500;
public static int RecentCount { get; set; } = 15; public static int RecentCount { get; set; } = 15;
public static float AutofitAudio { get; set; } = 0.8f;
public static float AutofitImage { get; set; } = 0.8f;
public static float MinimumAspectRatio { get; set; } public static float MinimumAspectRatio { get; set; }
public static float QuickBookmark { get; set; } public static float QuickBookmark { get; set; }
@@ -241,6 +243,8 @@ namespace mpvnet
case "audio-file-extensions": CorePlayer.AudioTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true; case "audio-file-extensions": CorePlayer.AudioTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
case "auto-load-folder": AutoLoadFolder = value == "yes"; return true; case "auto-load-folder": AutoLoadFolder = value == "yes"; return true;
case "auto-play": AutoPlay = value == "yes"; return true; case "auto-play": AutoPlay = value == "yes"; return true;
case "autofit-image": AutofitImage = value.Trim('%').ToInt() / 100f; return true;
case "autofit-audio": AutofitAudio = value.Trim('%').ToInt() / 100f; return true;
case "dark-mode": DarkMode = value; return true; case "dark-mode": DarkMode = value; return true;
case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true; case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true;
case "debug-mode": DebugMode = value == "yes"; return true; case "debug-mode": DebugMode = value == "yes"; return true;

View File

@@ -1,6 +1,7 @@
 
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
@@ -433,6 +434,12 @@ namespace mpvnet
Screen screen = Screen.FromControl(this); Screen screen = Screen.FromControl(this);
int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * Core.Autofit); int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * Core.Autofit);
if (App.AutofitAudio > 1) App.AutofitAudio = 1;
if (App.AutofitImage > 1) App.AutofitImage = 1;
if (Core.IsAudio) autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * App.AutofitAudio);
if (Core.IsImage) autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * App.AutofitImage);
if (Core.VideoSize.Height == 0 || Core.VideoSize.Width == 0 || if (Core.VideoSize.Height == 0 || Core.VideoSize.Width == 0 ||
Core.VideoSize.Width / (float)Core.VideoSize.Height < App.MinimumAspectRatio) Core.VideoSize.Width / (float)Core.VideoSize.Height < App.MinimumAspectRatio)

View File

@@ -146,7 +146,19 @@ namespace mpvnet
public string Path { get; set; } = ""; public string Path { get; set; } = "";
public string Command { get; set; } = ""; public string Command { get; set; } = "";
public string Display { get { return string.IsNullOrEmpty(Path) ? Command : Path; } }
public string Display {
get {
if (string.IsNullOrEmpty(Path))
{
if (Command.Length > 50)
return Command.Substring(0, 50) + "...";
return Command;
}
else
return Path;
}
}
public CommandItem() { } public CommandItem() { }

View File

@@ -21,8 +21,8 @@ namespace mpvnet
public class CorePlayer public class CorePlayer
{ {
public static string[] VideoTypes { get; set; } = "264 265 asf avc avi avs dav flv h264 h265 hevc m2t m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' '); public static string[] VideoTypes { get; set; } = "264 265 asf avc avi avs dav flv h264 h265 hevc m2t m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' ');
public static string[] AudioTypes { get; set; } = "aac ac3 dts dtshd dtshr dtsma eac3 flac m4a mka mp2 mp3 mpa mpc ogg opus thd thd+ac3 w64 wav".Split(' '); public static string[] AudioTypes { get; set; } = "aac ac3 dts dtshd dtshr dtsma eac3 flac m4a mka mp2 mp3 mpa mpc ogg opus thd w64 wav".Split(' ');
public static string[] ImageTypes { get; set; } = { "jpg", "bmp", "png", "gif" }; public static string[] ImageTypes { get; set; } = { "jpg", "bmp", "png", "gif", "webp" };
public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sub", "sup", "ttxt", "txt", "ssa", "smi", "mks" }; public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sub", "sup", "ttxt", "txt", "ssa", "smi", "mks" };
public event Action<mpv_log_level, string> LogMessageAsync; // log-message MPV_EVENT_LOG_MESSAGE public event Action<mpv_log_level, string> LogMessageAsync; // log-message MPV_EVENT_LOG_MESSAGE
@@ -56,9 +56,9 @@ namespace mpvnet
public event Action InitializedAsync; public event Action InitializedAsync;
public event Action Pause; public event Action Pause;
public event Action ShowMenu; public event Action ShowMenu;
public event Action<double> WindowScaleMpv;
public event Action<float> ScaleWindow; public event Action<float> ScaleWindow;
public event Action<float> WindowScaleNET; public event Action<float> WindowScaleNET;
public event Action<double> WindowScaleMpv;
public event Action<int> PlaylistPosChanged; public event Action<int> PlaylistPosChanged;
public event Action<int> PlaylistPosChangedAsync; public event Action<int> PlaylistPosChangedAsync;
public event Action<Size> VideoSizeChanged; public event Action<Size> VideoSizeChanged;
@@ -85,8 +85,9 @@ namespace mpvnet
public string ConfPath { get => ConfigFolder + "mpv.conf"; } public string ConfPath { get => ConfigFolder + "mpv.conf"; }
public string GPUAPI { get; set; } = "auto"; public string GPUAPI { get; set; } = "auto";
public string VO { get; set; } = "gpu";
public string InputConfPath => ConfigFolder + "input.conf"; public string InputConfPath => ConfigFolder + "input.conf";
public string Path { get; set; } = "";
public string VO { get; set; } = "gpu";
public string VID { get; set; } = ""; public string VID { get; set; } = "";
public string AID { get; set; } = ""; public string AID { get; set; } = "";
@@ -173,6 +174,7 @@ namespace mpvnet
SetPropertyString("idle", "yes"); SetPropertyString("idle", "yes");
ObservePropertyDouble("window-scale", value => WindowScaleMpv(value)); ObservePropertyDouble("window-scale", value => WindowScaleMpv(value));
ObservePropertyString("path", value => Path = value);
ObservePropertyBool("pause", value => { ObservePropertyBool("pause", value => {
Paused = value; Paused = value;
@@ -251,16 +253,22 @@ namespace mpvnet
switch (name) switch (name)
{ {
case "autofit": case "autofit":
if (int.TryParse(value.Trim('%'), out int result)) {
Autofit = result / 100f; if (int.TryParse(value.Trim('%'), out int result))
Autofit = result / 100f;
}
break; break;
case "autofit-smaller": case "autofit-smaller":
if (int.TryParse(value.Trim('%'), out int result2)) {
AutofitSmaller = result2 / 100f; if (int.TryParse(value.Trim('%'), out int result))
AutofitSmaller = result / 100f;
}
break; break;
case "autofit-larger": case "autofit-larger":
if (int.TryParse(value.Trim('%'), out int result3)) {
AutofitLarger = result3 / 100f; if (int.TryParse(value.Trim('%'), out int result))
AutofitLarger = result / 100f;
}
break; break;
case "fs": case "fs":
case "fullscreen": Fullscreen = value == "yes"; break; case "fullscreen": Fullscreen = value == "yes"; break;
@@ -333,7 +341,7 @@ namespace mpvnet
{ {
File.WriteAllText(_ConfigFolder + "input.conf", Properties.Resources.input_conf); File.WriteAllText(_ConfigFolder + "input.conf", Properties.Resources.input_conf);
string scriptOptsPath = _ConfigFolder + "script-opts" + Path.DirectorySeparatorChar; string scriptOptsPath = _ConfigFolder + "script-opts" + System.IO.Path.DirectorySeparatorChar;
if (!Directory.Exists(scriptOptsPath)) if (!Directory.Exists(scriptOptsPath))
{ {
@@ -438,7 +446,7 @@ namespace mpvnet
ps.Scripts.Add(eventCode); ps.Scripts.Add(eventCode);
ps.Scripts.Add(propertyChangedCode); ps.Scripts.Add(propertyChangedCode);
ps.Scripts.Add(File.ReadAllText(file)); ps.Scripts.Add(File.ReadAllText(file));
ps.Module = Path.GetFileName(file); ps.Module = System.IO.Path.GetFileName(file);
ps.Print = true; ps.Print = true;
lock (PowerShell.References) lock (PowerShell.References)
@@ -1195,7 +1203,7 @@ namespace mpvnet
LoadISO(file); LoadISO(file);
else if(SubtitleTypes.Contains(file.Ext())) else if(SubtitleTypes.Contains(file.Ext()))
CommandV("sub-add", file); CommandV("sub-add", file);
else if (file.Ext().Length != 3 && File.Exists(Path.Combine(file, "BDMV\\index.bdmv"))) else if (file.Ext().Length != 3 && File.Exists(System.IO.Path.Combine(file, "BDMV\\index.bdmv")))
{ {
Command("stop"); Command("stop");
Thread.Sleep(500); Thread.Sleep(500);
@@ -1284,7 +1292,7 @@ namespace mpvnet
path = path.Replace("/", "\\"); path = path.Replace("/", "\\");
if (path.Contains("\\")) if (path.Contains("\\"))
dir = Path.GetDirectoryName(path); dir = System.IO.Path.GetDirectoryName(path);
List<string> files = Directory.GetFiles(dir).ToList(); List<string> files = Directory.GetFiles(dir).ToList();
@@ -1388,6 +1396,10 @@ namespace mpvnet
void HideLogo() => Command("overlay-remove 0"); void HideLogo() => Command("overlay-remove 0");
public bool IsImage => ImageTypes.Contains(Path.Ext());
public bool IsAudio => AudioTypes.Contains(Path.Ext());
string GetLanguage(string id) string GetLanguage(string id)
{ {
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))

View File

@@ -410,6 +410,18 @@ file = mpv
filter = Screen filter = Screen
help = <int> Initial window height in percent. Default: 60 help = <int> Initial window height in percent. Default: 60
[setting]
name = autofit-image
file = mpvnet
filter = Screen
help = <int> Initial window height in percent for image files. Default: 80
[setting]
name = autofit-audio
file = mpvnet
filter = Screen
help = <int> Initial window height in percent for audio files. Default: 80
[setting] [setting]
name = autofit-smaller name = autofit-smaller
file = mpv file = mpv