Mario Mey Mario Mey - 6 months ago 23
Linux Question

How to control VLC from Pd Vanilla > 0.46 with native network system?

I want to connect Pure Data to VLC to control it (load files, play, stop, etc).

There is a way to do it by using pyext in https://github.com/mxa/AudioVideoPatches (file 15c-remote-vlc_python.pd), but I think that it is not necessary to use external code to do it (also, I couldn't get it to work). From version 0.48, Pd (Vanilla) has netsend and netreceive to connect to sockets natively.

I'm not familiar with sockets, so I don't know how to do it.

I'm on Ubuntu-Mate x64, Pd 0.46.7, VLC 2.1.6.

Answer

With some help from #dataflow (thanks to undah and dpro) and from pd-list (thanks to Jack), I could make the patch.

enter image description here

  • The fix was to send messages with [netsend -b] (as binary).
  • I converted some abstracts to subpatchs, to have all in one file.
  • It runs on Vanilla, it doesn't need any external.
  • If the playlist is long, it isn't shown complete. Same as Help.

Remember to open VLC in this way:

vlc -I rc --rc-host=localhost:1234

And then, open this patch:

#N canvas 302 295 1008 615 10;
#X obj 645 278 tgl 30 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X msg 74 105 disconnect;
#X obj 672 186 list prepend send;
#X obj 672 207 list trim;
#X msg 246 51 list play;
#X msg 250 127 list stop;
#X obj 40 282 bng 30 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 40 327 openpanel;
#X msg 40 408 list add \$1;
#X obj 672 144 list fromsymbol;
#X obj 672 165 list append 10;
#X msg 33 79 connect localhost 1234;
#X msg 250 88 list pause;
#X obj 782 328 list prepend;
#X obj 782 358 t l l;
#X obj 738 398 list;
#X obj 795 450 list tosymbol;
#X obj 795 502 print;
#X obj 40 430 s \$0-vlc;
#X obj 336 234 s \$0-vlc;
#X obj 672 51 r \$0-vlc;
#X obj 33 191 s \$0-to-netsend;
#X obj 645 14 r \$0-to-netsend;
#X obj 33 52 loadbang;
#X text 795 527 Messages from VLC, f 18;
#N canvas 1 62 766 673 list2symbol 0;
#X obj 168 348 list fromsymbol;
#N canvas 387 559 668 519 create_list 0;
#X obj 205 47 inlet;
#X msg 205 98 set;
#X obj 205 69 route clear bang;
#X obj 205 385 outlet;
#X msg 205 143 115 116 111 112 32;
#X obj 298 92 list prepend add2;
#X obj 298 114 list trim;
#X connect 0 0 2 0;
#X connect 1 0 4 0;
#X connect 2 0 1 0;
#X connect 2 1 4 0;
#X connect 2 2 5 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 6 0 4 0;
#X restore 168 449 pd create_list;
#X msg 484 230 clear;
#X obj 168 513 list tosymbol;
#X obj 168 545 outlet;
#X obj 429 45 inlet;
#X obj 168 46 inlet;
#X obj 168 68 list;
#X obj 168 103 t l b;
#X obj 168 250 t b s;
#X obj 168 297 t s s;
#X obj 456 299 loadbang;
#X msg 456 321 symbol;
#X obj 387 348 sel [symbol];
#X msg 387 370 0;
#X msg 456 370 -1;
#N canvas 1 84 450 300 remove_last_separator_if_it_exists 0;
#X obj 168 179 list split;
#X obj 168 110 t l l;
#X obj 195 136 list length;
#X obj 195 158 +;
#X obj 168 81 inlet;
#X obj 168 211 outlet;
#X obj 298 81 inlet;
#X connect 0 0 5 0;
#X connect 1 0 0 0;
#X connect 1 1 2 0;
#X connect 2 0 3 0;
#X connect 3 0 0 1;
#X connect 4 0 1 0;
#X connect 6 0 3 1;
#X restore 168 482 pd remove_last_separator_if_it_exists;
#X obj 168 370 route float list;
#X obj 168 175 route symbol;
#X obj 479 40 loadbang;
#X obj 429 157 route float;
#X obj 549 192 symbol;
#X obj 168 275 symbol;
#X text 482 551 Jack/RYBN 2014;
#X obj 479 63 list append \$1;
#X obj 479 85 route 0;
#X msg 479 107 32;
#X obj 479 129 makefilename %c;
#N canvas 1 60 553 698 float2symbol 0;
#X obj 168 635 outlet;
#X obj 168 46 inlet;
#X obj 168 201 pack f s;
#X msg 168 223 \$1\$2;
#X obj 168 245 symbol;
#X obj 300 112 loadbang;
#N canvas 46 628 450 300 remove_last_element 0;
#X obj 168 179 list split;
#X obj 168 110 t l l;
#X obj 195 136 list length;
#X obj 168 81 inlet;
#X obj 168 211 outlet;
#X obj 195 158 - 1;
#X connect 0 0 4 0;
#X connect 1 0 0 0;
#X connect 1 1 2 0;
#X connect 2 0 5 0;
#X connect 3 0 1 0;
#X connect 5 0 0 1;
#X restore 168 291 pd remove_last_element;
#X obj 168 313 list tosymbol;
#X obj 168 267 list fromsymbol;
#X obj 168 175 route float;
#X msg 300 153 symbol :;
#X text 335 474 Jack/RYBN 2014;
#X connect 1 0 9 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 8 0;
#X connect 5 0 10 0;
#X connect 6 0 7 0;
#X connect 7 0 0 0;
#X connect 8 0 6 0;
#X connect 9 0 2 0;
#X connect 10 0 2 1;
#X restore 237 214 pd float2symbol;
#N canvas 1 58 757 540 list-drip 0;
#X obj 63 84 t a a;
#X obj 63 241 spigot;
#X obj 102 149 bang;
#X obj 102 168 1;
#X obj 223 149 route bang;
#X obj 183 150 bang;
#X obj 183 169 0;
#X obj 102 114 list split 2;
#X obj 232 379 list split;
#X obj 299 328 list length;
#X obj 299 350 >> 1;
#X obj 63 260 t a a a a;
#X obj 63 446 list split;
#X obj 130 398 list length;
#X obj 130 423 >> 1;
#X obj 31 19 inlet;
#X obj 290 175 outlet;
#X text 73 19 Copyright 2009 by Mathieu Bouchard;
#X obj 31 53 t b a;
#X obj 465 119 outlet;
#X text 520 121 signal end of list;
#X text 381 23 made compatible with [list-drip]: fbar 2009;
#X connect 0 0 1 0;
#X connect 0 1 7 0;
#X connect 1 0 11 0;
#X connect 2 0 3 0;
#X connect 3 0 1 1;
#X connect 4 1 16 0;
#X connect 5 0 6 0;
#X connect 6 0 1 1;
#X connect 7 0 2 0;
#X connect 7 2 4 0;
#X connect 7 2 5 0;
#X connect 8 0 0 0;
#X connect 9 0 10 0;
#X connect 10 0 8 1;
#X connect 11 0 12 0;
#X connect 11 1 13 0;
#X connect 11 2 8 0;
#X connect 11 3 9 0;
#X connect 12 1 0 0;
#X connect 13 0 14 0;
#X connect 14 0 12 1;
#X connect 15 0 18 0;
#X connect 18 0 19 0;
#X connect 18 1 0 0;
#X restore 168 145 pd list-drip;
#N canvas 1 60 553 698 float2symbol 0;
#X obj 168 635 outlet;
#X obj 168 46 inlet;
#X obj 168 201 pack f s;
#X msg 168 223 \$1\$2;
#X obj 168 245 symbol;
#X obj 300 112 loadbang;
#N canvas 46 628 450 300 remove_last_element 0;
#X obj 168 179 list split;
#X obj 168 110 t l l;
#X obj 195 136 list length;
#X obj 168 81 inlet;
#X obj 168 211 outlet;
#X obj 195 158 - 1;
#X connect 0 0 4 0;
#X connect 1 0 0 0;
#X connect 1 1 2 0;
#X connect 2 0 5 0;
#X connect 3 0 1 0;
#X connect 5 0 0 1;
#X restore 168 291 pd remove_last_element;
#X obj 168 313 list tosymbol;
#X obj 168 267 list fromsymbol;
#X obj 168 175 route float;
#X msg 300 153 symbol :;
#X text 335 474 Jack/RYBN 2014;
#X connect 1 0 9 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 8 0;
#X connect 5 0 10 0;
#X connect 6 0 7 0;
#X connect 7 0 0 0;
#X connect 8 0 6 0;
#X connect 9 0 2 0;
#X connect 10 0 2 1;
#X restore 429 189 pd float2symbol;
#X connect 0 0 17 0;
#X connect 1 0 16 0;
#X connect 2 0 1 0;
#X connect 3 0 4 0;
#X connect 5 0 20 0;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 8 0 29 0;
#X connect 8 1 2 0;
#X connect 9 0 22 0;
#X connect 9 1 0 0;
#X connect 10 0 0 0;
#X connect 10 1 13 0;
#X connect 11 0 12 0;
#X connect 12 0 13 1;
#X connect 13 0 14 0;
#X connect 13 1 15 0;
#X connect 14 0 16 1;
#X connect 15 0 16 1;
#X connect 16 0 3 0;
#X connect 17 0 1 0;
#X connect 17 1 1 0;
#X connect 18 0 9 0;
#X connect 18 1 28 0;
#X connect 19 0 24 0;
#X connect 20 0 30 0;
#X connect 20 1 21 0;
#X connect 21 0 22 1;
#X connect 22 0 10 0;
#X connect 24 0 25 0;
#X connect 25 0 26 0;
#X connect 25 1 20 0;
#X connect 26 0 27 0;
#X connect 27 0 20 0;
#X connect 28 0 9 0;
#X connect 29 0 18 0;
#X connect 29 1 1 0;
#X connect 30 0 22 1;
#X restore 672 119 pd list2symbol;
#X obj 179 282 bng 30 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 179 386 openpanel;
#X obj 179 431 s \$0-vlc;
#X msg 179 408 list enqueue \$1;
#X text 412 50 Clear Playlist;
#X msg 336 50 list clear;
#X text 75 288 Open one file;
#X msg 67 386 list clear;
#X text 213 281 Enqueue file to the playlist, f 15;
#X obj 40 360 t a b;
#X obj 645 251 netsend -b, f 11;
#X obj 719 276 route 10 13;
#X obj 719 304 t b b b;
#X obj 738 420 route bang;
#X msg 401 157 list quit;
#X msg 401 174 list logout;
#X msg 401 191 list shutdown;
#X msg 382 109 list help;
#X msg 372 85 list playlist;
#X text 463 85 Print Playlist;
#X text 446 109 Print Help (incomplete);
#X msg 795 472 \$1;
#X connect 1 0 21 0;
#X connect 2 0 3 0;
#X connect 3 0 36 0;
#X connect 4 0 19 0;
#X connect 5 0 19 0;
#X connect 6 0 7 0;
#X connect 7 0 35 0;
#X connect 8 0 18 0;
#X connect 9 0 10 0;
#X connect 10 0 2 0;
#X connect 11 0 21 0;
#X connect 12 0 19 0;
#X connect 13 0 14 0;
#X connect 14 0 15 1;
#X connect 14 1 13 1;
#X connect 15 0 39 0;
#X connect 16 0 47 0;
#X connect 20 0 25 0;
#X connect 22 0 36 0;
#X connect 23 0 11 0;
#X connect 25 0 9 0;
#X connect 26 0 27 0;
#X connect 27 0 29 0;
#X connect 29 0 28 0;
#X connect 31 0 19 0;
#X connect 33 0 18 0;
#X connect 35 0 8 0;
#X connect 35 1 33 0;
#X connect 36 0 0 0;
#X connect 36 1 37 0;
#X connect 37 0 38 0;
#X connect 37 1 38 0;
#X connect 37 2 13 0;
#X connect 38 0 15 1;
#X connect 38 1 15 0;
#X connect 38 2 13 1;
#X connect 39 1 16 0;
#X connect 40 0 19 0;
#X connect 41 0 19 0;
#X connect 42 0 19 0;
#X connect 43 0 19 0;
#X connect 44 0 19 0;
#X connect 47 0 17 0;

EDIT: I uploaded a newer version to PatchStorage, called VLC Controller.

Comments