{"id":931,"date":"2013-07-29T21:25:02","date_gmt":"2013-07-30T02:25:02","guid":{"rendered":"http:\/\/trillworks.com\/nick\/?p=931"},"modified":"2013-08-15T14:44:39","modified_gmt":"2013-08-15T19:44:39","slug":"control-streaming-audio-on-a-remote-pc-with-node-js","status":"publish","type":"post","link":"https:\/\/trillworks.com\/nick\/2013\/07\/29\/control-streaming-audio-on-a-remote-pc-with-node-js\/","title":{"rendered":"Control streaming audio on a remote PC with node.js"},"content":{"rendered":"<p>Over the weekend I got impatient waiting for my Chromecast to arrive so I built <a href=\"https:\/\/github.com\/NickCarneiro\/netbook-web-streamer\">netbook-web-streamer<\/a>. It&#8217;s a node.js app that loads URLs in an iframe on a remote PC that&#8217;s plugged into your large speakers. I use it to listen to playlists on songza and individual songs from youtube.<\/p>\n<p>To play a song, enter it in the form on the homepage, or click the bookmarklet when you&#8217;re on a page you want the remote PC to load.<\/p>\n<p><a href=\"http:\/\/trillworks.com\/nick\/wp-content\/uploads\/2013\/07\/Screen-Shot-2013-07-29-at-9.17.38-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-932\" alt=\"netbook audio streamer UI\" src=\"http:\/\/trillworks.com\/nick\/wp-content\/uploads\/2013\/07\/Screen-Shot-2013-07-29-at-9.17.38-PM-300x279.png\" width=\"300\" height=\"279\" srcset=\"https:\/\/trillworks.com\/nick\/wp-content\/uploads\/2013\/07\/Screen-Shot-2013-07-29-at-9.17.38-PM-300x279.png 300w, https:\/\/trillworks.com\/nick\/wp-content\/uploads\/2013\/07\/Screen-Shot-2013-07-29-at-9.17.38-PM.png 670w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>How this works<\/strong><\/p>\n<p>There are 3 routes `&#8217;\/&#8217;`, `&#8217;\/loadUrl&#8217;`, and `&#8217;\/audio&#8217;`.<\/p>\n<p>`\/` is the homepage. From there you can send xhr GET requests to `\/loadUrl` with a `&amp;url` param. The node.js view then broadcasts a socket.io event to a client that has loaded `\/audio`. The event handler on the client takes the url value from the message and loads it in an iframe.<\/p>\n<p>The only complication is that youtube forbids running videos on the main site in an iframe by sending an x-frame-options header. The workaround is to extract the video id from the url and turn it into an embed url.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the weekend I got impatient waiting for my Chromecast to arrive so I built netbook-web-streamer. It&#8217;s a node.js app that loads URLs in an iframe on a remote PC that&#8217;s plugged into your large speakers. I use it to listen to playlists on songza and individual songs from youtube. To play a song, enter &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/trillworks.com\/nick\/2013\/07\/29\/control-streaming-audio-on-a-remote-pc-with-node-js\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Control streaming audio on a remote PC with node.js&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[],"class_list":["post-931","post","type-post","status-publish","format-standard","hentry","category-technical"],"_links":{"self":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts\/931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/comments?post=931"}],"version-history":[{"count":6,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts\/931\/revisions"}],"predecessor-version":[{"id":954,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/posts\/931\/revisions\/954"}],"wp:attachment":[{"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/media?parent=931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/categories?post=931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trillworks.com\/nick\/wp-json\/wp\/v2\/tags?post=931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}