Chromecast hack for devs

Frank ScherFrank Scher
2 min read

What is this about?

I have an iPhone and a Chromecast. I like music in the background, and my new TV has crisp sound and an “audio-only” mode, which I love!

Although I could just cast Youtube, it sucks more and more because of the ads, plus I am subscribed to Apple Music!

Quickly reading online tells me this needs a $9.99/month app… Hell no!

Aren’t I a Software Engineer? I tell myself: If there is a better solution than spending $120/year I’ll find it!

There is, and I found it: project your phone screen to your laptop and cast your laptop’s audio to your Chromecast.

Time to prepare: 2-3 minutes.

Ingredients:

  • Linux laptop (if you are on Mac, projecting the iPhone is probably even easier…)

  • UXPlay to cast your phone audio/video to your laptop.

  • MKChromecast to cast your audio to your Chromecast.

  • Profit!

UXPlay

$ sudo apt-get install uxplay
$ uxplay

Now your iPhone can be cast to your laptop:

Although UXPlay is pretty stable, remember you’ll be locking your phone, and that can lead to unexpected disconnections, but we are software engineers, aren’t we? Wrap the invocation like this while [ 1 ]; do uxplay; done; and you’ll be good.

MKChromecast

$ sudo apt-get install mkchromecast
$ mkchromecast

That’s it; assuming your Chromecast is in the same network as your laptop, you are now casting your phone’s audio to it.

Similar to UXPlay, there might be unexpected disconnections, but it is even easier than with UXPlay: mkchromecast has a --tries parameter, give it a ridiculously high number and you have fault-tolerance:

$ mkchromecast --tries 1000

Now point your audio sink to use MKChromecast:

Profit!

You jam on your TV! Click below to see it in action:

It even boots the TV if it is off! If anything I observe a slight delay when jumping between songs, additional tweaking might improve that but I really don’t care!

Project(s) shout-out: UXPlay, MKChromecast, XUbuntu

0
Subscribe to my newsletter

Read articles from Frank Scher directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Frank Scher
Frank Scher