Fix #421 crash choosing Matroska edition in the menu.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
- Fix crash choosing Matroska edition in the menu.
|
||||||
- Fix auto-play not working with user scripts.
|
- Fix auto-play not working with user scripts.
|
||||||
- When input.conf is created on the very first start and a
|
- When input.conf is created on the very first start and a
|
||||||
script-opts folder does not exist, a script-opts folder
|
script-opts folder does not exist, a script-opts folder
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace mpvnet
|
|||||||
static void Execute(string file)
|
static void Execute(string file)
|
||||||
{
|
{
|
||||||
string code = File.ReadAllText(file);
|
string code = File.ReadAllText(file);
|
||||||
string filename = Path.GetFileNameWithoutExtension(file) + " " + StringHelp.GetMD5Hash(code) + ".dll";
|
string filename = Path.GetFileNameWithoutExtension(file) + " " + StringHelp.GetMD5Hash(code) + "-v5.dll";
|
||||||
string outputFile = Path.Combine(Path.GetTempPath(), filename);
|
string outputFile = Path.Combine(Path.GetTempPath(), filename);
|
||||||
|
|
||||||
if (!File.Exists(outputFile))
|
if (!File.Exists(outputFile))
|
||||||
|
|||||||
@@ -164,8 +164,6 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowInfo()
|
public static void ShowInfo()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string performer, title, album, genre, date, duration, text = "";
|
string performer, title, album, genre, date, duration, text = "";
|
||||||
long fileSize = 0;
|
long fileSize = 0;
|
||||||
@@ -232,11 +230,6 @@ namespace mpvnet
|
|||||||
|
|
||||||
Core.CommandV("show-text", text, "5000");
|
Core.CommandV("show-text", text, "5000");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
App.ShowException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static string FormatTime(double value) => ((int)value).ToString("00");
|
static string FormatTime(double value) => ((int)value).ToString("00");
|
||||||
|
|
||||||
|
|||||||
@@ -676,12 +676,10 @@ namespace mpvnet
|
|||||||
IsLogoVisible = false;
|
IsLogoVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Command(string command, bool throwException = false)
|
public void Command(string command)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_command_string(Handle, command);
|
mpv_error err = mpv_command_string(Handle, command);
|
||||||
|
HandleError(err, "error executing command:", command);
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, "error executing command:", command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CommandV(params string[] args)
|
public void CommandV(params string[] args)
|
||||||
@@ -705,9 +703,7 @@ namespace mpvnet
|
|||||||
Marshal.FreeHGlobal(ptr);
|
Marshal.FreeHGlobal(ptr);
|
||||||
|
|
||||||
Marshal.FreeHGlobal(rootPtr);
|
Marshal.FreeHGlobal(rootPtr);
|
||||||
|
HandleError(err, "error executing command:", string.Join("\n", args));
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, true, "error executing command:", string.Join("\n", args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Expand(string value)
|
public string Expand(string value)
|
||||||
@@ -742,7 +738,7 @@ namespace mpvnet
|
|||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
HandleError(err, true, "error executing command:", string.Join("\n", args));
|
HandleError(err, "error executing command:", string.Join("\n", args));
|
||||||
Marshal.FreeHGlobal(resultNodePtr);
|
Marshal.FreeHGlobal(resultNodePtr);
|
||||||
return "property expansion error";
|
return "property expansion error";
|
||||||
}
|
}
|
||||||
@@ -754,86 +750,68 @@ namespace mpvnet
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetPropertyBool(string name, bool throwException = false)
|
public bool GetPropertyBool(string name)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||||
mpv_format.MPV_FORMAT_FLAG, out IntPtr lpBuffer);
|
mpv_format.MPV_FORMAT_FLAG, out IntPtr lpBuffer);
|
||||||
|
HandleError(err, $"error getting property: {name}");
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error getting property: {name}");
|
|
||||||
|
|
||||||
return lpBuffer.ToInt32() != 0;
|
return lpBuffer.ToInt32() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPropertyBool(string name, bool value, bool throwException = false)
|
public void SetPropertyBool(string name, bool value)
|
||||||
{
|
{
|
||||||
long val = value ? 1 : 0;
|
long val = value ? 1 : 0;
|
||||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, ref val);
|
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, ref val);
|
||||||
|
HandleError(err, $"error setting property: {name} = {value}");
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetPropertyInt(string name, bool throwException = false)
|
public int GetPropertyInt(string name)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||||
mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer);
|
mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer);
|
||||||
|
if (App.DebugMode)
|
||||||
if (err < 0)
|
HandleError(err, $"error getting property: {name}");
|
||||||
HandleError(err, throwException, $"error getting property: {name}");
|
|
||||||
|
|
||||||
return lpBuffer.ToInt32();
|
return lpBuffer.ToInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPropertyInt(string name, int value, bool throwException = false)
|
public void SetPropertyInt(string name, int value)
|
||||||
{
|
{
|
||||||
long val = value;
|
long val = value;
|
||||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val);
|
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val);
|
||||||
|
HandleError(err, $"error setting property: {name} = {value}");
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPropertyLong(string name, long value, bool throwException = false)
|
public void SetPropertyLong(string name, long value)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref value);
|
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref value);
|
||||||
|
HandleError(err, $"error setting property: {name} = {value}");
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetPropertyLong(string name, bool throwException = false)
|
public long GetPropertyLong(string name)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||||
mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer);
|
mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer);
|
||||||
|
HandleError(err, $"error getting property: {name}");
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error getting property: {name}");
|
|
||||||
|
|
||||||
return lpBuffer.ToInt64();
|
return lpBuffer.ToInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetPropertyDouble(string name, bool throwException = false)
|
public double GetPropertyDouble(string name)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||||
mpv_format.MPV_FORMAT_DOUBLE, out double value);
|
mpv_format.MPV_FORMAT_DOUBLE, out double value);
|
||||||
|
if (App.DebugMode)
|
||||||
if (err < 0)
|
HandleError(err, $"error getting property: {name}");
|
||||||
HandleError(err, throwException, $"error getting property: {name}");
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPropertyDouble(string name, double value, bool throwException = false)
|
public void SetPropertyDouble(string name, double value)
|
||||||
{
|
{
|
||||||
double val = value;
|
double val = value;
|
||||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, ref val);
|
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, ref val);
|
||||||
|
HandleError(err, $"error setting property: {name} = {value}");
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error setting property: {name} = {value}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetPropertyString(string name, bool throwException = false)
|
public string GetPropertyString(string name)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||||
mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
|
mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
|
||||||
@@ -845,20 +823,20 @@ namespace mpvnet
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleError(err, throwException, $"error getting property: {name}");
|
if (App.DebugMode)
|
||||||
|
HandleError(err, $"error getting property: {name}");
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPropertyString(string name, string value, bool throwException = false)
|
public void SetPropertyString(string name, string value)
|
||||||
{
|
{
|
||||||
byte[] bytes = GetUtf8Bytes(value);
|
byte[] bytes = GetUtf8Bytes(value);
|
||||||
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes);
|
mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes);
|
||||||
|
HandleError(err, $"error setting property: {name} = " + value);
|
||||||
if (err < 0)
|
|
||||||
HandleError(err, throwException, $"error setting property: {name} = " + value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetPropertyOsdString(string name, bool throwException = false)
|
public string GetPropertyOsdString(string name)
|
||||||
{
|
{
|
||||||
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name),
|
||||||
mpv_format.MPV_FORMAT_OSD_STRING, out IntPtr lpBuffer);
|
mpv_format.MPV_FORMAT_OSD_STRING, out IntPtr lpBuffer);
|
||||||
@@ -870,7 +848,7 @@ namespace mpvnet
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleError(err, throwException, $"error getting property: {name}");
|
HandleError(err, $"error getting property: {name}");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,7 +884,7 @@ namespace mpvnet
|
|||||||
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_INT64);
|
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_INT64);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
HandleError(err, true, $"error observing property: {name}");
|
HandleError(err, $"error observing property: {name}");
|
||||||
else
|
else
|
||||||
IntPropChangeActions[name] = new List<Action<int>>();
|
IntPropChangeActions[name] = new List<Action<int>>();
|
||||||
}
|
}
|
||||||
@@ -925,7 +903,7 @@ namespace mpvnet
|
|||||||
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_DOUBLE);
|
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_DOUBLE);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
HandleError(err, true, $"error observing property: {name}");
|
HandleError(err, $"error observing property: {name}");
|
||||||
else
|
else
|
||||||
DoublePropChangeActions[name] = new List<Action<double>>();
|
DoublePropChangeActions[name] = new List<Action<double>>();
|
||||||
}
|
}
|
||||||
@@ -944,7 +922,7 @@ namespace mpvnet
|
|||||||
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_FLAG);
|
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_FLAG);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
HandleError(err, true, $"error observing property: {name}");
|
HandleError(err, $"error observing property: {name}");
|
||||||
else
|
else
|
||||||
BoolPropChangeActions[name] = new List<Action<bool>>();
|
BoolPropChangeActions[name] = new List<Action<bool>>();
|
||||||
}
|
}
|
||||||
@@ -963,7 +941,7 @@ namespace mpvnet
|
|||||||
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_STRING);
|
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_STRING);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
HandleError(err, true, $"error observing property: {name}");
|
HandleError(err, $"error observing property: {name}");
|
||||||
else
|
else
|
||||||
StringPropChangeActions[name] = new List<Action<string>>();
|
StringPropChangeActions[name] = new List<Action<string>>();
|
||||||
}
|
}
|
||||||
@@ -982,7 +960,7 @@ namespace mpvnet
|
|||||||
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_NONE);
|
mpv_error err = mpv_observe_property(Handle, 0, name, mpv_format.MPV_FORMAT_NONE);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
HandleError(err, true, $"error observing property: {name}");
|
HandleError(err, $"error observing property: {name}");
|
||||||
else
|
else
|
||||||
PropChangeActions[name] = new List<Action>();
|
PropChangeActions[name] = new List<Action>();
|
||||||
}
|
}
|
||||||
@@ -992,15 +970,14 @@ namespace mpvnet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleError(mpv_error err, bool throwException, params string[] messages)
|
public void HandleError(mpv_error err, params string[] messages)
|
||||||
{
|
{
|
||||||
if (throwException)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
foreach (string msg in messages)
|
foreach (string msg in messages)
|
||||||
Terminal.WriteError(msg);
|
Terminal.WriteError(msg);
|
||||||
|
|
||||||
Terminal.WriteError(GetError(err));
|
Terminal.WriteError(GetError(err));
|
||||||
throw new Exception(string.Join(BR2, messages) + BR2 + GetError(err) + BR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,8 +995,6 @@ namespace mpvnet
|
|||||||
string arg = i;
|
string arg = i;
|
||||||
|
|
||||||
if (arg.StartsWith("-") && arg.Length > 1)
|
if (arg.StartsWith("-") && arg.Length > 1)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (!preInit)
|
if (!preInit)
|
||||||
{
|
{
|
||||||
@@ -1083,7 +1058,7 @@ namespace mpvnet
|
|||||||
ProcessProperty(left, right);
|
ProcessProperty(left, right);
|
||||||
|
|
||||||
if (!App.ProcessProperty(left, right))
|
if (!App.ProcessProperty(left, right))
|
||||||
SetPropertyString(left, right, true);
|
SetPropertyString(left, right);
|
||||||
}
|
}
|
||||||
else if (!preInit && !preInitProperties.Contains(left))
|
else if (!preInit && !preInitProperties.Contains(left))
|
||||||
{
|
{
|
||||||
@@ -1091,18 +1066,13 @@ namespace mpvnet
|
|||||||
|
|
||||||
if (!App.ProcessProperty(left, right))
|
if (!App.ProcessProperty(left, right))
|
||||||
{
|
{
|
||||||
SetPropertyString(left, right, true);
|
SetPropertyString(left, right);
|
||||||
|
|
||||||
if (left == "shuffle" && right == "yes")
|
if (left == "shuffle" && right == "yes")
|
||||||
shuffle = true;
|
shuffle = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
App.ShowException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preInit)
|
if (!preInit)
|
||||||
@@ -1503,8 +1473,11 @@ namespace mpvnet
|
|||||||
|
|
||||||
for (int i = 0; i < editionCount; i++)
|
for (int i = 0; i < editionCount; i++)
|
||||||
{
|
{
|
||||||
|
string title = GetPropertyString($"edition-list/{i}/title");
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
title = "Edition " + i;
|
||||||
MediaTrack track = new MediaTrack();
|
MediaTrack track = new MediaTrack();
|
||||||
track.Text = "E: " + GetPropertyString($"edition-list/{i}/title");
|
track.Text = "E: " + title;
|
||||||
track.Type = "e";
|
track.Type = "e";
|
||||||
track.ID = i;
|
track.ID = i;
|
||||||
MediaTracks.Add(track);
|
MediaTracks.Add(track);
|
||||||
|
|||||||
@@ -90,15 +90,7 @@ namespace mpvnet
|
|||||||
if (item.File == "mpv")
|
if (item.File == "mpv")
|
||||||
{
|
{
|
||||||
Core.ProcessProperty(item.Name, item.Value);
|
Core.ProcessProperty(item.Name, item.Value);
|
||||||
|
Core.SetPropertyString(item.Name, item.Value);
|
||||||
try
|
|
||||||
{
|
|
||||||
Core.SetPropertyString(item.Name, item.Value, true);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
App.ShowError(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (item.File == "mpvnet")
|
else if (item.File == "mpvnet")
|
||||||
App.ProcessProperty(item.Name, item.Value, true);
|
App.ProcessProperty(item.Name, item.Value, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user