Listen to Your Home iTunes Collection from Work

It’s a well-known bummer that the iTunes “Share” feature only works over your local LAN. You may have no intention of sharing your music collection with the world, or of running your own little public radio station from home, but you simply can’t connect to an iTunes library from another network. It’s a feature, not a bug.

feature-bug

Of course, iTunes Match is meant to solve exactly this problem, but Match has a fatal flaw that makes it unusable by the people who need it the most – its 25,000 song limit. For those of us with legit collections of 50k or 75k tracks, Match isn’t an option. Shame, too – I’d happily pay 2x or 3x the subscription price to get Match working. It’s the answer to my prayers, but off-limits. Apple won’t take my money to solve this problem.

So what if you just want to be able to listen to music on a Mac at home from work? It is possible, but it’ll take some setup work, and 60 bucks (which is one-time fee, and money you won’t have to pay to Apple, Pandora, rdio, MOG or Spotify). And, in my experience, those streaming services only have about half the music in my collection – if I want to listen to my music from work, this is the only option.

The setup works like this:

  • Audio Consumption: Broadcast a personal “radio station” from the remote (home) iTunes and subscribe to that stream from the local (work) iTunes
  • Playback Control: A VNC client or Apple’s Screen Sharing

In other words, you’ll be listening through iTunes at work, but you’ll be listening to a “radio station.” To skip tracks, create or switch playlists, rate tracks, or do anything interesting, you’ll need to be able to control your home computer from work.

To get this working, you’ll need two pieces in place on the home (server) side:

  • Securely enable access and control of your home desktop from outside of your home LAN
  • A tool to broadcast music emanating from iTunes over the internet

You’ll need two pieces in place at the network layer (router):

  • A way to consistently access your ever-changing home IP address
  • Port forwarding enabled in your router

Two pieces in place on the work (client) side:

  • Software to access/control your home desktop
  • A client to consume the private broadcast

1) Home: Desktop sharing

Go to System Preferences | Sharing and enable the Screen Sharing option. This will allow authenticated VNC or Screen Sharing clients to connect to and control your computer from other machines. Allow only Administrators. Click Computer Settings and select “May control with password” and create a control password.

sharing1

Ignore the IP addresses it offers for access – there’s a better way, which we’ll get to in a bit.

Broadcast Over the Internet from iTunes

Screen Sharing will let you control your desktop remotely, but it doesn’t do audio! For that, you’ll need a broadcast server to create your own personal radio station. For that, I use Rogue Amoeba’s excellent Nicecast app, which knows how to hijack audio from iTunes and pump it out as a protected stream (technically, Nicecast is a friendly wrapper around the open source Icecast broadcast package). Nicecast costs $60, but is free to try with streams lasting one hour or less.  Technically, you could do this for free with Icecast alone, but Nicecast makes things WAY easier. Well worth the price of admission, IMO.

Nicecast needs little explanation – just install it, configure it to hijack the stream from iTunes, and check all of its configuration tabs. I set it up for high-quality 256kbps streaming, since much of my audio is Apple Lossless.

nicecast

There’s a “Check Connection” button on the Share tab in Nicecast which you’ll definitely want to use after starting your broadcast, since it will test whether your stream is accessible to the outside world. That’s a matter of router configuration, which comes next, but be sure to read the relevant sections of the Nicecast Help manual carefully if you run into trouble.

Get a Consistent Address to Access Your Home Computer from Outside

Most home users get a dynamic IP from their ISP, which means you might have to connect to an audio stream at a different IP every day. But you don’t want to have to keep track of your ever-changing IP address. Services like DynDNS solve this problem for you, detecting changes to your address and hiding them behind a consistent address, like yourname.dyndns.org.

In the olden days, you needed to install a DynDNS client on your computer to detect IP changes and update the DynDNS service. But most modern routers have DynDNS built right in. So the first thing you’ll need to do is to register for a free account at dyndns.org and set up a username/address.

Next, access your router’s config interface and look for something like “Dynamic DNS” or “DDNS.” Here’s what it looks like in the typical Linksys router admin:

linksdyn

Once that’s set up, your router will automatically detect when the IP address assigned to it by your ISP changes, and alert the DynDNS service, so that your permanent yourname.dyndns.org adddress stays accessible and you never have to think about your changing IP.

If your router doesn’t have this feature built in, you’ll need to download the computer client software from DynDNS and keep it running in the background.

Home Network Setup

Your home network uses “internal” IP addresses, typically starting with 192.168.x.x or 10.1.x.x Those IP addresses are not accessible from outside your home by default, and all devices connected to your home router share the same external IP address. For example, if you check your Mac or Windows network settings, you’ll probably see that you’re using a 192.168.x.x IP address, but if you visit a site like whatismyip.com you’ll see the public IP address of your router, which is completely different (your WAN (wide area network) address).

To make this work, you’ll need to set your computer to a static internal IP address, and configure your router to forward requests for certain servies on to that particular machine on your internal network. This is called port forwarding.

First, make sure your computer doesn’t grab a new internal IP address every time it boots. On the Mac, go to System Preferences | Network, and select your main network interface. Click the Advanced… button, select the TCP/IP tab at the top. Note what it currently says in the IPv4 Address field – most likely an address starting with 192.168.1.xxx.

Change “Using DHCP” to “Using DHCP with manual address” and enter the address you noted above. That will be the permanent internal IP of this computer from now on, even after reboots. This step is important because the router to know which computer on your network is handling traffic for remote desktop control and audio broadcasts. By setting the address manually, it will never change after reboots, and the router will always be able to find it on your internal network.

manual-addr

Click Apply and presto, you’re on a static internal IP.

Port Forwarding

Different network services travel across specific “ports”. For example, web servers usually run on port 80 or 443. You’ll need to configure your router to intercept all requests for Mac OS X Screen Sharing, and for the Nicecast server, to the internal IP you selected. Screen Sharing uses ports 5900 and 3283, and Nicecast uses port 8000. On many Linksys routers, this is configured via “Applications and Gaming | Port Range Forward” … but check for anything you can find in your router config related to port forwarding. You’ll want to set up something like this:

port-screen

Use the port addresses shown here, but set the IP addresses to match the IP you established above (you might not need the ssh entry – geeks only on that one).

Connecting from Work

The music consumption side is a bit different from what you’re used to – since your remote desktop control software (VNC or Screen Sharing) won’t be able to pipe audio to your work computer, you’ll be separating the playback control system from consumption of the audio stream itself.

Traditionally, controlling a remote desktop is accomplished with a VNC client such as Chicken or Jolly’s VNC. While VNC clients work pretty well from within the same LAN where bandwidth is super fast, remote VNC (outside the LAN) is maddeningly slow. But for Mac users, the key to faster remote desktop control is hidden right under your nose – you don’t need VNC, you need Screen Sharing, which has been built into every version of Mac OS since 10.4.

Screen Sharing is VNC-compatible, so once you’ve set up Screen Sharing on the host computer in Sharing Preferences, you can connect to it with either a VNC client or a remote Mac Screen Sharing instance.

If you’ve ever listened to a radio station in iTunes,  you know you can’t skip tracks from there any more than you can skip tracks with your car radio. In other words, if you want to skip to the next track, you’ll do it from your Screen Sharing client at work, directly controlling the source of the “radio station.”

elastic

Mac Screen Sharing provides an “elastic zoom” feature. By zooming in on the area of focus, Screen Sharing gives you a great way to view a larger remote desktop from a smaller local client. For example, connecting to a 27″ iMac from a 15″ Macbook Pro. To change the elastic zoom area, just drag sideways or up/down.

But you can’t launch the Screen Sharing client directly, like a normal app – it’s meant to be launched by other services. Here’s a cool one-time technique to set it up for 1-click access:

  1. Launch Safari and go to the URL vnc://[yourname].dyndns.org (this is where your earlier DynDNS setup work pays off).
  2. Safari will throw a dialog to “Connect to a Shared Computer.” Enter the password you created in the Mac Screen Sharing step above. Click “Remember this password” (if you’re OK with that) and click Connect.
  3. If all of your port forwarding / router work earlier went well, you should now see and be able to control your remote desktop.
  4. To save the connection for future one-click use, pull down Connection | Save As … and save the Screen Sharing connection somewhere permanent (I put mine in Documents/Remote Connections). Go to that location in the Finder and drag it to the Documents section of your Dock. For feel-good sexytime, you might want to give it a custom icon.
  5. Pull down View | Enter Full Screen (or click the full-screen icon at top-right). This will cause the remote connection to occupy a desktop of its own on your work Mac. You can now switch to your remote connection from Mission Control, or with a three-finger swipe (left or right) on a Magic Mouse or trackpad. Experiment with the various Screen Sharing view options to work with your setup (e.g. your host machine’s screen may either be larger or smaller than the client machine).

Now that you’re controlling the host machine from afar, start remote iTunes playback.

n.b. If you sometimes use AirPlay to toggle between the standard Computer and an Airport Express device for output, make sure iTunes audio output is being routed to Computer.

Setting up an Audio Client

Of course, you won’t hear anything yet, since Screen Sharing doesn’t do audio (and neither does VNC). Instead, you’ll be using Nicecast to broadcast a personal “radio station,” which you’ll be listening to via iTunes on the client (work) computer.

On the host, launch Nicecast and click Start Broadcast. Nicecast will report the IP it’s broadcasting over, such as:

http://79.222.213.147:8003/listen.m3u

But thankfully,  you don’t need to worry about the IP, since you set up DynDNS earlier.  In iTunes on the client computer, pull down File | Open Stream and enter

http://[yourname].dyndns.org:8003/listen.m3u

Your port address may vary, but this should work in most cases. Double-check your port-forwarding settings if it doesn’t match.

To make your station easy to find in your work copy of iTunes, put it in its own playlist (I already had a “Radio Stations” playlist, so I stuck it there).

If you don’t want to run iTunes for some reason, you can also subscribe to the stream from QuickTime or other clients (even on Windows!), but iTunes is a great choice since the Mac keyboard’s play/pause keys are pre-mapped to iTunes.

Tip: When you play iTunes remotely, its output will come from the home speakers even as Nicecast duplicates its stream “over the air.” If there are people in your house, you might want to punch the mute key on the host computer before leaving home so music doesn’t also spill out into the house.

Biggest remaining problem: What happens when your kid comes home from school at 3pm and starts playing Minecraft on the host? Sorry, can’t help you with that. Just be glad you have an awesome kid.

For best results: Make sure all of your albums have the best quality album cover art!  Use CoverScout if some of yours are missing. If CoverScout can’t find high-res covers for some of your tracks, scan or photograph them yourself! It’s worth it. Once you have ubiquitous cover art, click the cover icon in the remote iTunes to bring up a large version of your covers. Awesome experience.

Thanks to David the Expert for:
The Very Best VNC Client for Mac OS X is Right Under Your Nose!

 

2 thoughts on “Listen to Your Home iTunes Collection from Work

  1. So-Called Bill

    What I really want to do is stream and control my home iTunes from my iPhone. Have you figured that one out?

Leave a Reply