This commit is contained in:
Frank Skare
2019-06-24 09:00:01 +02:00
parent 63f064ba1c
commit d32c7b4056
3 changed files with 28 additions and 34 deletions

View File

@@ -1,9 +1,10 @@
### ###
- clipboard-monitoring was replaced by url-whitelist: - clipboard-monitoring was replaced by url-whitelist:
Domain whitelist to monitor the clipboard for URLs to play. Keyword whitelist to monitor the clipboard for URLs to play.
Default: youtube ard zdf Default: tube vimeo ard zdf
- some settings like colors didn't work because enclosing quotes were missing - 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 - the playlist is never cleared whenever the control key is down but
files and URLs are appended instead files and URLs are appended instead

View File

@@ -26,7 +26,7 @@ namespace mpvnet
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[] 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[] 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[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
public static string[] UrlWhitelist { get; set; } = { "youtube", "ard", "zdf" }; public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
public static bool DebugMode { get; set; } = false; public static bool DebugMode { get; set; } = false;

View File

@@ -167,7 +167,7 @@ namespace mpvnet
foreach (var scriptPath in startupScripts) foreach (var scriptPath in startupScripts)
if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower())) if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower()))
mp.commandv("load-script", $"{scriptPath}"); commandv("load-script", $"{scriptPath}");
foreach (var scriptPath in startupScripts) foreach (var scriptPath in startupScripts)
if (Path.GetExtension(scriptPath) == ".py") if (Path.GetExtension(scriptPath) == ".py")
@@ -177,8 +177,8 @@ namespace mpvnet
if (Path.GetExtension(scriptPath) == ".ps1") if (Path.GetExtension(scriptPath) == ".ps1")
PowerShellScript.Init(scriptPath); PowerShellScript.Init(scriptPath);
if (Directory.Exists(mp.ConfFolder + "Scripts")) if (Directory.Exists(ConfFolder + "Scripts"))
foreach (var scriptPath in Directory.GetFiles(mp.ConfFolder + "Scripts")) foreach (var scriptPath in Directory.GetFiles(ConfFolder + "Scripts"))
if (Path.GetExtension(scriptPath) == ".py") if (Path.GetExtension(scriptPath) == ".py")
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath))); PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
else if (Path.GetExtension(scriptPath) == ".ps1") else if (Path.GetExtension(scriptPath) == ".ps1")
@@ -232,7 +232,7 @@ namespace mpvnet
case mpv_event_id.MPV_EVENT_FILE_LOADED: case mpv_event_id.MPV_EVENT_FILE_LOADED:
HideLogo(); HideLogo();
FileLoaded?.Invoke(); FileLoaded?.Invoke();
WriteHistory(mp.get_property_string("path")); WriteHistory(get_property_string("path"));
break; break;
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED: case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
TracksChanged?.Invoke(); TracksChanged?.Invoke();
@@ -242,8 +242,7 @@ namespace mpvnet
break; break;
case mpv_event_id.MPV_EVENT_IDLE: case mpv_event_id.MPV_EVENT_IDLE:
Idle?.Invoke(); Idle?.Invoke();
if (mp.get_property_int("playlist-count") == 0) if (get_property_int("playlist-count") == 0) ShowLogo();
ShowLogo();
break; break;
case mpv_event_id.MPV_EVENT_PAUSE: case mpv_event_id.MPV_EVENT_PAUSE:
Pause?.Invoke(); Pause?.Invoke();
@@ -350,7 +349,7 @@ namespace mpvnet
{ {
if (IsLogoVisible) if (IsLogoVisible)
{ {
mp.commandv("overlay-remove", "0"); commandv("overlay-remove", "0");
IsLogoVisible = false; IsLogoVisible = false;
} }
} }
@@ -441,18 +440,14 @@ namespace mpvnet
try try
{ {
int err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer); 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); string ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer); mpv_free(lpBuffer);
return ret; return ret;
} }
catch (Exception ex) catch (Exception e)
{ {
if (throwOnException) throw ex; if (throwOnException) throw e;
return ""; return "";
} }
} }
@@ -542,7 +537,7 @@ namespace mpvnet
} }
} }
mp.Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control)); Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control));
foreach (string i in args) foreach (string i in args)
{ {
@@ -552,10 +547,10 @@ namespace mpvnet
{ {
string left = i.Substring(2, i.IndexOf("=") - 2); string left = i.Substring(2, i.IndexOf("=") - 2);
string right = i.Substring(left.Length + 3); string right = i.Substring(left.Length + 3);
mp.set_property_string(left, right); set_property_string(left, right);
} }
else else
mp.set_property_string(i.Substring(2), "yes"); set_property_string(i.Substring(2), "yes");
} }
} }
} }
@@ -567,20 +562,22 @@ namespace mpvnet
for (int i = 0; i < files.Length; i++) for (int i = 0; i < files.Length; i++)
if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower())) if (App.SubtitleTypes.Contains(Path.GetExtension(files[i]).TrimStart('.').ToLower()))
mp.commandv("sub-add", files[i]); commandv("sub-add", files[i]);
else else
if (i == 0 && !append) if (i == 0 && !append)
mp.commandv("loadfile", files[i]); commandv("loadfile", files[i]);
else else
mp.commandv("loadfile", files[i], "append"); commandv("loadfile", files[i], "append");
if (string.IsNullOrEmpty(get_property_string("path")))
set_property_int("playlist-pos", 0);
if (loadFolder && !append) Task.Run(() => LoadFolder()); // user reported race condition if (loadFolder && !append) Task.Run(() => LoadFolder()); // user reported race condition
} }
static void LoadFolder() static void LoadFolder()
{ {
Thread.Sleep(50); // user reported race condition Thread.Sleep(50); // user reported race condition
string path = mp.get_property_string("path"); string path = get_property_string("path");
if (!File.Exists(path) || get_property_int("playlist-count") != 1) return; if (!File.Exists(path) || get_property_int("playlist-count") != 1) return;
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList(); List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
files = files.Where((file) => files = files.Where((file) =>
@@ -644,7 +641,7 @@ namespace mpvnet
if (File.Exists(LastHistoryPath) && totalMinutes > 1) 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) + File.AppendAllText(historyFilepath, DateTime.Now.ToString().Substring(0, 16) +
" " + totalMinutes.ToString().PadLeft(3) + " " + " " + totalMinutes.ToString().PadLeft(3) + " " +
@@ -671,7 +668,7 @@ namespace mpvnet
Rectangle r = new Rectangle(cr.Width / 2 - iconWidth / 2, cr.Height / 2 - iconWidth / 2, iconWidth, iconWidth); Rectangle r = new Rectangle(cr.Width / 2 - iconWidth / 2, cr.Height / 2 - iconWidth / 2, iconWidth, iconWidth);
g.DrawImage(Properties.Resources.mpvnet, r); g.DrawImage(Properties.Resources.mpvnet, r);
BitmapData bd = b.LockBits(cr, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb); 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()); commandv("overlay-add", "0", "0", "0", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString());
b.UnlockBits(bd); b.UnlockBits(bd);
IsLogoVisible = true; IsLogoVisible = true;
} }
@@ -685,15 +682,11 @@ namespace mpvnet
case "autofit": case "autofit":
if (value.Length == 3 && value.EndsWith("%")) if (value.Length == 3 && value.EndsWith("%"))
if (int.TryParse(value.Substring(0, 2), out int result)) if (int.TryParse(value.Substring(0, 2), out int result))
mp.Autofit = result / 100f; Autofit = result / 100f;
break; break;
case "fs": case "fs":
case "fullscreen": case "fullscreen": Fullscreen = value == "yes"; break;
mp.Fullscreen = value == "yes"; case "screen": Screen = Convert.ToInt32(value); break;
break;
case "screen":
mp.Screen = Convert.ToInt32(value);
break;
} }
} }
@@ -703,7 +696,7 @@ namespace mpvnet
{ {
MediaTracks.Clear(); 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); int count = mi.GetCount(MediaInfoStreamKind.Video);