summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2019-12-19 15:35:20 +0200
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2019-12-19 16:23:19 +0200
commit3460a7b6960f4be76bed91ab9e20b7d7a82a335b (patch)
treed63393500ab351aadec843406ea8c0a62e16bb42
parent4fc5cd32d022fbc898052bbc5beda2e618137aa4 (diff)
downloadmpv-3460a7b6960f4be76bed91ab9e20b7d7a82a335b.tar.bz2
mpv-3460a7b6960f4be76bed91ab9e20b7d7a82a335b.tar.xz
js: support shared script properties (match 7e4819e7)
-rw-r--r--player/javascript/defaults.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js
index d85653bd3f..9694b852d7 100644
--- a/player/javascript/defaults.js
+++ b/player/javascript/defaults.js
@@ -170,6 +170,28 @@ mp.abort_async_command = function abort_async_command(id) {
mp._abort_async_command(id);
}
+// shared-script-properties - always an object, even if without properties
+function shared_script_property_set(name, val) {
+ if (arguments.length > 1)
+ return mp.commandv("change-list", "shared-script-properties", "append", "" + name + "=" + val);
+ else
+ return mp.commandv("change-list", "shared-script-properties", "remove", name);
+}
+
+function shared_script_property_get(name) {
+ return mp.get_property_native("shared-script-properties")[name];
+}
+
+function shared_script_property_observe(name, cb) {
+ return mp.observe_property("shared-script-properties", "native",
+ function shared_props_cb(_name, val) { cb(name, val[name]) }
+ );
+}
+
+mp.utils.shared_script_property_set = shared_script_property_set;
+mp.utils.shared_script_property_get = shared_script_property_get;
+mp.utils.shared_script_property_observe = shared_script_property_observe;
+
/**********************************************************************
* key bindings
*********************************************************************/