How to Stream Audio from Linux to Chromecast and Google Home

How to Stream Audio from Linux to Chromecast and Google Home

As our homes fill up with streaming devices, we have to manage them from all of our machines, including Linux boxes. In this article, we show you how to stream audio and video from your Linux machine to Chromecast and Google Home.

Use MKCHROMECAST

Mkchromecast is a program for streaming audio and video from your macOS or Linux desktop to your Google Cast devices or Sonos speakers. It is written in Python and comes with packages for Debian and Ubuntu. If your repositories are up to date, you can open a terminal and type:

It is also available in Ubuntu software and can be installed with one click.

After installation, you will find Mkchromecast in your Applications folder. Launch it and you should see the service icon appear at the top right of your screen. By default, the icon is not set to match Ubuntu’s dark theme, but you can upgrade to a lighter icon set. Click on the icon and choose Preferences.

Screenshot showing Mkchromecast settings.

There are three options for icon colors. Choose the one you prefer and close the window. Surprisingly, nothing happens, but if you click the icon again and select “Search for streaming media devices” the change will take effect.

Screenshot of all Chromecast and Google Home devices available on the network.Screenshot of all Chromecast and Google Home devices available on the network.

Select “Search for media streaming devices” to see everything that is accessible on your network. It may take about a minute for all of your devices to appear.

You can now select your destination from the list of available devices and the icon changes to include a small playhead. This means that the device is ready to take a stream. We noticed that by default Mkchromecast set the device’s volume to 0, so it’s a good idea to select the Volume option and set it to something reasonable.

Pavucontrol screenshot showing the Output Devices tab where you can select Mkchromecast to stream audio.Pavucontrol screenshot showing the Output Devices tab where you can select Mkchromecast to stream audio.

Pulse Audio Control to manage the pipes

To direct the audio to the correct device, we choose to use a second software, called Pulse Audio software control (search for “pavucontrol”), available from Ubuntu Software. This has five tabs at the top. Start under “Output devices” to make sure Mkchromecast is listed and active. You will also see your standard output speakers as a hardware device. There is a volume slider to change the volume and a lock button to sync streams across multiple devices, although we’re pulling out one at a time.

Screenshot showing the Play tab of pavucontrol where you can select the device you want to send to the Chromecast.Screenshot showing the Play tab of pavucontrol where you can select the device you want to send to the Chromecast.

Then you need a source. We use MPV Media Player for local playback. Launch the source and add a file such as MP3 or wav. Under Pulse Audio Playback in a tab, you should now see an entry for System Sounds and Media Player. By default, the media player will be configured for playback on your standard output.

Select the button next to the media player and choose Mkchromecast.

Now when you press play in media player, the sound will come out from the selected device. You can go back into the Mkchromecast system tray app and select different devices, and the audio should change.

Stream local files from Chrome

The second option is perhaps the easiest, but also uses more system resources as it runs in Chrome or in the open source Chromium browser.

Screenshot showing native streaming of a remote file (by Look Mum No Computer) to one of our Chromecast devices.Screenshot showing native streaming of a remote file (by Look Mum No Computer) to one of our Chromecast devices.

Chrome has its own native streaming system, so you can open a web radio station or web app like Spotify, then go to the menu and select Cast to see a list of available devices. Select the device and the sound will start playing.

You can also select a device, click in the Sources list at the bottom, and select “Stream file” if you want to listen to a local file. A file selector appears and you can choose a track to start playing. The problem with this is that it’s all or nothing – there’s no real control over play or pause and no chance to adjust the volume except on the device itself.

Screenshot showing the Local Audio Player extension doing its job.  Who plays local audio.Screenshot showing the Local Audio Player extension doing its job.  Who plays local audio.

A good alternative is the Local audio player extension, available on the Chrome Web Store. This allows you to select a file to play, adjust the volume, or set a sleep timer to go off after a certain amount of time. It’s great for audiobooks!

This extension requires a small adjustment before use, so once installed, go to “Menu -> Extensions”, select Local audio player and click on the Details button. Halfway down the page you will see a switch on “Allow access to file URLs”.

The local audio player needs a little adjustment to stream local files.  This screenshot shows how to do this.Local audio player needs a little tweaking to stream local files.  This screenshot shows how to do this.

You can now drag a local file into the browser and a player will launch. You can do “Menu -> Cast” and select your device, then press Play. Again, you can select different devices and the audio should move to the correct location.

Now you can enjoy sound in any room in your home where you can plug in a Google Home or Chromecast device. Maybe you even want to enhance the experience with some PulseEffects to even out some of the dynamics in your music or boost the bass.

If you don’t have a Chromecast, you can also build it yourself using a Raspberry Pi.

Related:

Andy Channelle

Andy Channelle is a writer and web developer who has written for Linux Format, Mac Format, 3D World, and others, and has also published bestselling books on Ubuntu Linux and OpenOffice.org. He recently worked on web projects and campaigns for the International Red Cross and the UN. It produces – but hardly ever publishes – electronics under the name Collision Detector. Andy lives in Wales, UK.

Is this article useful?

!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘400239050508508’);
fbq(‘track’, ‘PageView’);

Leave a Comment

Your email address will not be published. Required fields are marked *