-
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
// when seeking displays position and
|
||||
// duration like so: 00:00 / 120:00
|
||||
// this is different from MPC which
|
||||
// uses 00:00:00 / 02:00:00
|
||||
|
||||
function add_zero(val)
|
||||
{
|
||||
val = Math.round(val);
|
||||
return val > 9 ? "" + val : "0" + val;
|
||||
}
|
||||
|
||||
function format(val)
|
||||
{
|
||||
var sec = Math.round(val);
|
||||
|
||||
if (sec < 0)
|
||||
sec = 0;
|
||||
|
||||
pos_min_floor = Math.floor(sec / 60);
|
||||
sec_rest = sec - pos_min_floor * 60;
|
||||
return add_zero(pos_min_floor) + ":" + add_zero(sec_rest);
|
||||
}
|
||||
|
||||
function on_seek(_)
|
||||
{
|
||||
mp.commandv("show-text",
|
||||
format(mp.get_property_number("time-pos")) + " / " +
|
||||
format(mp.get_property_number("duration")));
|
||||
}
|
||||
|
||||
mp.register_event("seek", on_seek);
|
||||
@@ -7,7 +7,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using static mpvnet.libmpv;
|
||||
using static mpvnet.Native;
|
||||
using static mpvnet.StaticUsing;
|
||||
@@ -75,6 +75,7 @@ namespace mpvnet
|
||||
SetStringProp("wid", MainForm.Hwnd.ToString());
|
||||
SetStringProp("force-window", "yes");
|
||||
mpv_initialize(MpvHandle);
|
||||
LoadScripts();
|
||||
ProcessCommandLine();
|
||||
Task.Run(() => { Addon = new Addon(); });
|
||||
Task.Run(() => { EventLoop(); });
|
||||
@@ -343,5 +344,18 @@ namespace mpvnet
|
||||
}
|
||||
|
||||
public static byte[] GetUtf8Bytes(string s) => Encoding.UTF8.GetBytes(s + "\0");
|
||||
|
||||
public static void LoadScripts()
|
||||
{
|
||||
foreach (var i in Directory.GetFiles(Application.StartupPath + "\\Scripts"))
|
||||
{
|
||||
string[] extensions = { ".lua", ".js" };
|
||||
|
||||
if (!extensions.Contains(Path.GetExtension(i).ToLower()))
|
||||
continue;
|
||||
|
||||
mpv.Command("load-script", $"{i}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user