Showing the changes to player/javascript (1 of 1 file). Show all
Unified · Split
| @@ -170,6 +170,28 @@ mp.abort_async_command = function abort_async_command(id) { · 169 unmodified lines | |||
| 170 | mp._abort_async_command(id); | 170 | mp._abort_async_command(id); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | // shared-script-properties - always an object, even if without properties | ||
| 174 | function shared_script_property_set(name, val) { | ||
| 175 | if (arguments.length > 1) | ||
| 176 | return mp.commandv("change-list", "shared-script-properties", "append", "" + name + "=" + val); | ||
| 177 | else | ||
| 178 | return mp.commandv("change-list", "shared-script-properties", "remove", name); | ||
| 179 | } | ||
| 180 | |||
| 181 | function shared_script_property_get(name) { | ||
| 182 | return mp.get_property_native("shared-script-properties")[name]; | ||
| 183 | } | ||
| 184 | |||
| 185 | function shared_script_property_observe(name, cb) { | ||
| 186 | return mp.observe_property("shared-script-properties", "native", | ||
| 187 | function shared_props_cb(_name, val) { cb(name, val[name]) } | ||
| 188 | ); | ||
| 189 | } | ||
| 190 | |||
| 191 | mp.utils.shared_script_property_set = shared_script_property_set; | ||
| 192 | mp.utils.shared_script_property_get = shared_script_property_get; | ||
| 193 | mp.utils.shared_script_property_observe = shared_script_property_observe; | ||
| 194 | |||
| 173 | /********************************************************************** | 195 | /********************************************************************** |
| 174 | * key bindings | 196 | * key bindings |
| 175 | *********************************************************************/ | 197 | *********************************************************************/ |