summaryrefslogtreecommitdiffstats
path: root/player/javascript
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2020-01-08 11:07:36 +0200
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2020-01-08 11:49:49 +0200
commit5e0875c9e04e6773575703b50264ea39c39bf56c (patch)
tree66ad1fd68dc97d52c314719255469fdd2030c1e3 /player/javascript
parentf612de17129054c915c23b18241988a284f0baa5 (diff)
downloadmpv-5e0875c9e04e6773575703b50264ea39c39bf56c.tar.bz2
mpv-5e0875c9e04e6773575703b50264ea39c39bf56c.tar.xz
js: use osd-dimentions for mp.get_osd_{size,margins}
This matches lua's 11b9315b but with the lagacy field names which the js code used previously. Currently the property always returns an object (with dummy/last/null field values if there are no dimensions), but the code is ready for a future case where it might return null if there are no dimensions - at which case it will forward the null, breaking backward compatibility for a better API.
Diffstat (limited to 'player/javascript')
-rw-r--r--player/javascript/defaults.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js
index 18edab35b7..0a1c99bcef 100644
--- a/player/javascript/defaults.js
+++ b/player/javascript/defaults.js
@@ -238,11 +238,14 @@ mp.set_osd_ass = function set_osd_ass(res_x, res_y, data) {
return mp._legacy_overlay.update();
}
+// the following return undefined on error, null passthrough, or legacy object
mp.get_osd_size = function get_osd_size() {
- var w = mp.get_property_number("osd-width", 0),
- h = mp.get_property_number("osd-height", 0),
- par = mp.get_property_number("osd-par", 0);
- return {width: w, height: h, aspect: w / (h || 1) / (par || 1)};
+ var d = mp.get_property_native("osd-dimensions");
+ return d && {width: d.w, height: d.h, aspect: d.aspect};
+}
+mp.get_osd_margins = function get_osd_margins() {
+ var d = mp.get_property_native("osd-dimensions");
+ return d && {left: d.ml, right: d.mr, top: d.mt, bottom: d.mb};
}
/**********************************************************************