History

js: support mp.create_osd_overlay (match 07287262)

The legacy mp.set_osd_ass(...) is still supported (but also still undocumented) as a wrapper for the new mp.create_osd_overlay(...).

Avi Halachmi (:avih) committed 6 years ago

Commit 9f2fda71 parent 5a74bf53 files · +57 −23Browse files

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

Unified · Split

player/javascript/defaults.js+53−0
@@ -192,6 +192,59 @@ mp.utils.shared_script_property_set = shared_script_property_set; · 191 unmodified lines
192192 mp.utils.shared_script_property_get = shared_script_property_get;
193193 mp.utils.shared_script_property_observe = shared_script_property_observe;
194194
195+// osd-ass
196+var next_assid = 1;
197+mp.create_osd_overlay = function create_osd_overlay(format) {
198+ return {
199+ format: format || "ass-events",
200+ id: next_assid++,
201+ data: "",
202+ res_x: 0,
203+ res_y: 720,
204+ z: 0,
205+
206+ update: function ass_update() {
207+ mp.command_native({
208+ name: "osd-overlay",
209+ format: this.format,
210+ id: this.id,
211+ data: this.data,
212+ res_x: Math.round(this.res_x),
213+ res_y: Math.round(this.res_y),
214+ z: this.z,
215+ });
216+ return mp.last_error() ? undefined : true;
217+ },
218+
219+ remove: function ass_remove() {
220+ mp.command_native({
221+ name: "osd-overlay",
222+ id: this.id,
223+ format: "none",
224+ data: "",
225+ });
226+ return mp.last_error() ? undefined : true;
227+ },
228+ };
229+}
230+
231+// osd-ass legacy API
232+mp.set_osd_ass = function set_osd_ass(res_x, res_y, data) {
233+ if (!mp._legacy_overlay)
234+ mp._legacy_overlay = mp.create_osd_overlay("ass-events");
235+ mp._legacy_overlay.res_x = res_x;
236+ mp._legacy_overlay.res_y = res_y;
237+ mp._legacy_overlay.data = data;
238+ return mp._legacy_overlay.update();
239+}
240+
241+mp.get_osd_size = function get_osd_size() {
242+ var w = mp.get_property_number("osd-width", 0),
243+ h = mp.get_property_number("osd-height", 0),
244+ par = mp.get_property_number("osd-par", 0);
245+ return {width: w, height: h, aspect: w / (h || 1) / (par || 1)};
246+}
247+
195248 /**********************************************************************
196249 * key bindings
197250 *********************************************************************/

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