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.
Showing the changes to player/javascript (1 of 2 files). Show all
Unified · Split
| @@ -238,11 +238,14 @@ mp.set_osd_ass = function set_osd_ass(res_x, res_y, data) { · 237 unmodified lines | |||
| 238 | return mp._legacy_overlay.update(); | 238 | return mp._legacy_overlay.update(); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | // the following return undefined on error, null passthrough, or legacy object | ||
| 241 | mp.get_osd_size = function get_osd_size() { | 242 | mp.get_osd_size = function get_osd_size() { |
| 242 | var w = mp.get_property_number("osd-width", 0), | 243 | var d = mp.get_property_native("osd-dimensions"); |
| 243 | h = mp.get_property_number("osd-height", 0), | 244 | return d && {width: d.w, height: d.h, aspect: d.aspect}; |
| 244 | par = mp.get_property_number("osd-par", 0); | 245 | } |
| 245 | return {width: w, height: h, aspect: w / (h || 1) / (par || 1)}; | 246 | mp.get_osd_margins = function get_osd_margins() { |
| 247 | var d = mp.get_property_native("osd-dimensions"); | ||
| 248 | return d && {left: d.ml, right: d.mr, top: d.mt, bottom: d.mb}; | ||
| 246 | } | 249 | } |
| 247 | 250 | ||
| 248 | /********************************************************************** | 251 | /********************************************************************** |