2

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.

Max N
  • 1,134
  • 11
  • 23
Mario Mey
  • 1,582
  • 3
  • 13
  • 13
  • 1
    Well, after some tests, I solved this issue (it's easy and direct)... but there's a problem. Any message sent to VLC has a ";" at the end ("add file.avi" is "add file.avi;"). And, until I resolve this problem, I can't post the answer to this question. – Mario Mey May 05 '16 at 16:01
  • 1
    IOhannes told me that the last ";" is normal, it is the format that Pd messages are transmitted in, called FUDI: https://en.wikipedia.org/wiki/FUDI – Mario Mey May 06 '16 at 20:19

2 Answers2

1

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.

Mario Mey
  • 1,582
  • 3
  • 13
  • 13
  • Doesn't work for me. connecting stream socket: Connection refused (111) – Max N May 29 '16 at 14:23
  • Did you start VLC as "vlc -I rc --rc-host=localhost:1234"? If I don't run VLC in that way, Pd says "connecting stream socket: Connection refused (111)". – Mario Mey May 30 '16 at 02:56
  • Yes. VLC media player 2.1.6 Rincewind (revision 2.1.6+git20160115+r54594+20+11~ubuntu14.04.1) on Mint Cinnamon – Max N May 30 '16 at 05:28
  • I got rid of that error, but I still see no VLC window. – Max N May 30 '16 at 08:17
  • Here is a screenshot of this utility working: https://dl.dropboxusercontent.com/u/13242430/vlc-controller.webm – Mario Mey May 31 '16 at 13:19
  • If you run VLC before PureData, the connection is automatically. If you do it the other way around, you have to connect (using connect button) until "Is connected" is True. – Mario Mey May 31 '16 at 13:21
  • It looks the same here, except there is no video window. – Max N May 31 '16 at 14:25
  • Sorry, man. I don't know how to help you. It would be great if VLC had the option to print also in the console. It sends all the messages only backward to Pure Data, in this case. No messages at the console to know what's happening. Maybe it's a socket issue... I don't understand so much about them (I didn't know about them until I need to use them with VLC). – Mario Mey Jun 02 '16 at 01:32
1

the solution to not seeing the VLC window requires a different approach altogether. 1) [i am on macos 10.12] go to the VLC preferences > show all > interface > main interfaces and activate "Lua interpreter" and "Remote control" (oldrc:lua). Under the respective Lua tab in the menu I added a localhost:4212 port (variable maybe) in the Lua-Telnet field (this may not be even necessary). --> without setting this up in the VLC preferences, it will not allow the connections when in GUI mode (hence the connection socket is refused when it isn't opened in the background) 2) open VLC in this way: vlc --rc-host=localhost:4212; the VLC will open. Using the ggee/shell obj (ggee library), this command can be sent from Pure Data itself to set up the VLC from within the patch 3) connect to localhost 4212 in Pure Data, VLC will respond and everything is connected and ready to go (including fullscreen command etc.). I successfuly set up the patch so that when I start it, VLC is being launched, a custom video is chosen, played back and set to fullscreen and looping.

Oni Shogun
  • 11
  • 1