This commit is contained in:
Frank Skare
2019-04-06 16:03:46 +02:00
parent 39f6f4de0d
commit 4492a423b4
11 changed files with 100 additions and 38 deletions

View File

@@ -360,15 +360,23 @@ namespace mpvnet
public static string get_property_string(string name, bool throwOnException = false)
{
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
try
{
int err = mpv_get_property(MpvHandle, 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}");
var ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
var ret = StringFromNativeUtf8(lpBuffer);
mpv_free(lpBuffer);
return ret;
return ret;
}
catch (Exception ex)
{
if (throwOnException) throw ex;
return "";
}
}
public static int get_property_int(string name, bool throwOnException = false)