Semantics changes are the same as at 548ef078 . Also, the previous C implementation returnd a string for the `stdout` value, but stdout of the subprocess command is MPV_FORMAT_BYTE_ARRAY which js previously didn't support, so support it too (at pushnode) by returning it as a string - the same as the lua code does.
Showing the changes to player/javascript (1 of 2 files). Show all
Unified · Split
| @@ -538,6 +538,20 @@ mp.osd_message = function osd_message(text, duration) { · 537 unmodified lines | ||
| 538 | 538 | mp.commandv("show_text", text, Math.round(1000 * (duration || -1))); |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | +mp.utils.subprocess = function subprocess(t) { | |
| 542 | + var cmd = { name: "subprocess", capture_stdout: true }; | |
| 543 | + var new_names = { cancellable: "playback_only", max_size: "capture_size" }; | |
| 544 | + for (var k in t) | |
| 545 | + cmd[new_names[k] || k] = t[k]; | |
| 546 | + | |
| 547 | + var rv = mp.command_native(cmd); | |
| 548 | + if (mp.last_error()) /* typically on missing/incorrect args */ | |
| 549 | + rv = { error_string: mp.last_error(), status: -1 }; | |
| 550 | + if (rv.error_string) | |
| 551 | + rv.error = rv.error_string; | |
| 552 | + return rv; | |
| 553 | +} | |
| 554 | + | |
| 541 | 555 | // ----- dump: like print, but expands objects/arrays recursively ----- |
| 542 | 556 | function replacer(k, v) { |
| 543 | 557 | var t = typeof v; |