History

js: reimplement subprocess using the subprocess command (match 548ef078)

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.

Avi Halachmi (:avih) committed 7 years ago

Commit fea39b51 parent 5b5f7762 files · +21 −72Browse files

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

Unified · Split

player/javascript/defaults.js+14−0
@@ -538,6 +538,20 @@ mp.osd_message = function osd_message(text, duration) { · 537 unmodified lines
538538 mp.commandv("show_text", text, Math.round(1000 * (duration || -1)));
539539 }
540540
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+
541555 // ----- dump: like print, but expands objects/arrays recursively -----
542556 function replacer(k, v) {
543557 var t = typeof v;

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