History

js: support shared script properties (match 7e4819e7)

Avi Halachmi (:avih) committed 6 years ago

Commit 3460a7b1 parent 4fc5cd31 file · +22 −0Browse files

Showing the changes to player/javascript (1 of 1 file). Show all

Unified · Split

player/javascript/defaults.js+22−0
@@ -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
174function 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
181function shared_script_property_get(name) {
182 return mp.get_property_native("shared-script-properties")[name];
183}
184
185function 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
191mp.utils.shared_script_property_set = shared_script_property_set;
192mp.utils.shared_script_property_get = shared_script_property_get;
193mp.utils.shared_script_property_observe = shared_script_property_observe;
194
173/**********************************************************************195/**********************************************************************
174 * key bindings196 * key bindings
175 *********************************************************************/197 *********************************************************************/

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t