{"id":894,"date":"2016-12-20T09:24:02","date_gmt":"2016-12-20T09:24:02","guid":{"rendered":"http:\/\/tech.avant.net\/q\/?p=894"},"modified":"2019-04-30T15:58:38","modified_gmt":"2019-04-30T15:58:38","slug":"vlc-remote-control","status":"publish","type":"post","link":"https:\/\/tech.avant.net\/q\/vlc-remote-control\/","title":{"rendered":"VLC remote control"},"content":{"rendered":"<p>Recently I was using <a href=\"http:\/\/www.videolan.org\/vlc\">VLC<\/a> to listen to music, as I often do, and I wanted to pause without getting out of bed.<\/p>\n<p>Lazy? Yes!<\/p>\n<p>I learned that VLC includes a slew of remote control interfaces, including a built-in web interface as well as a raw socket interface.<\/p>\n<p>In VLC Advanced Preferences, go to &#8220;Interface&#8221;, and then &#8220;Main interfaces&#8221; for a list of options. I selected &#8220;Remote control&#8221; which is now known as &#8220;oldrc&#8221;, and I configured a simple file based socket &#8220;vlc.sock&#8221; in my home directory as an experiment.<\/p>\n<p>You can use netcat to send commands, for example,<\/p>\n<pre class=\"sh_sh\">twarnock@laptop:~ :) nc -U ~\/vlc.sock &lt;&lt;&lt; \"pause\"\n<\/pre>\n<p>Best of all VLC cleans up after itself and removes the socket file when it closes. The &#8220;remote control&#8221; interface is pretty intuitive and comes with a &#8220;help&#8221; command. I wrapped all of this in a shell function (in a .bashrc).<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">function vlcrc() {\n SOCK=~\/vlc.sock\n CMD=\"pause\"\n if [ $# -gt 0 ]; then\n  CMD=$1\n fi\n if [ -S $SOCK ]; then\n  nc -U $SOCK &lt;&lt;&lt; \"$CMD\"\n else\n  (&gt;&amp;2 echo \"I can't find VLC socket $SOCK\")\n fi\n}<\/pre>\n<p><a href=\"http:\/\/tech.avant.net\/q\/wp-content\/uploads\/2017\/06\/0.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-medium wp-image-898\" src=\"http:\/\/tech.avant.net\/q\/wp-content\/uploads\/2017\/06\/0-169x300.png\" alt=\"\" width=\"169\" height=\"300\" srcset=\"https:\/\/tech.avant.net\/q\/wp-content\/uploads\/2017\/06\/0-169x300.png 169w, https:\/\/tech.avant.net\/q\/wp-content\/uploads\/2017\/06\/0.png 562w\" sizes=\"(max-width: 169px) 100vw, 169px\" \/><\/a><\/p>\n<p>I like this approach because I can now use &#8220;vlc <em>command<\/em>&#8221; in a scripted environment. I can build playlists, control the volume, adjust the playback speed, pretty much anything VLC lets me do. I could even use a crontab and make a scripted alarm clock!<\/p>\n<p>And of course I can &#8220;pause&#8221; my music from my phone while laying in bed. Granted, there&#8217;s apps for more user friendly VLC smartphone remotes, but I like the granular control provided by a command line.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was using VLC to listen to music, as I often do, and I wanted to pause without getting out of bed. Lazy? Yes! I learned that VLC includes a slew of remote control interfaces, including a built-in web interface as well as a raw socket interface. In VLC Advanced Preferences, go to &#8220;Interface&#8221;, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/894"}],"collection":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/comments?post=894"}],"version-history":[{"count":9,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/894\/revisions"}],"predecessor-version":[{"id":951,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/894\/revisions\/951"}],"wp:attachment":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/media?parent=894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/categories?post=894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/tags?post=894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}