Stream Music from Linux to Google Home

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
340
Reaction score
367
Credits
11,754
If anyone has a Google Hub device of some sort, they know how handy they can be for getting information when you ask a question. But there is another use that most people may not be aware of doing. Streaming music, not only to one speaker, to many.

Personally, I have six Google Home Devices. Five are speakers and one is a display/speaker.

NOTE: I also have my ceiling fan, lamp, printer and a black light hooked to Google Home. The printer is plugged into an ‘outdoor heavy-duty’ extension cord that is controlled by Google Home. When I tell Google to turn on the printer, the plug powers on and the printer starts. I can power on the printer from any room.

Installation

The program we will use is the ‘mkchromecast’ app. To install the app in Ubuntu, use the following command:

Code:
sudo apt install mkchromecast

Once you’ve installed the app, the Linux system needs to be connected to the same Wi-Fi network as the Google Home Speaker to which you want to play music.

The ‘mkchromecast’ icon should appear in your task area (near your clock), as shown in Figure 1.

FIgure 1.jpg

FIGURE 1

If you right-click on the icon, you should see an option for ‘Preferences’. Figure 2 shows the default settings which should work fine for casting music.

Figure 2.jpg

FIGURE 2

Casting


We should be able to cast to a Google device in a short while. There are only a few items to change to allow the streaming to start.

Right-click on the ‘mkchromecast’ icon and select the top option ‘Search for Media Streaming Devices’. The app may take 10-30 seconds to scan for available devices on the network. Once the scan completes, a list of devices should appear, giving you the option to choose one. The names displayed are taken from the names given them from the Home app. See Figure 3 for an example of the pop-up menu.

Figure 3.jpg

FIGURE 3

Choose one of the Home Devices listed and then play a song using any audio player, such as VLC. Once you select a Google device, you should after a bit hear a tone from the speaker showing that it is being accessed remotely.

You will not hear any music from the Google speaker yet, it should play from your default system speakers. To switch to the chosen Google speaker, you need to type ‘pavucontrol’ from a prompt to start the ‘Volume Control’ app. Under the ‘Playback’ tab, you should see the app you chose to play music. Choose the box that lists the default speaker and change it to ‘Mkchromecast’. Set the volume accordingly for the output. It may take up to 10 seconds before the music starts.

Any system sound will come out of the Google Speaker at this point. Any program that you play any sound or music from will be cast to the Google Speaker.

Set up a long playlist and you are set for a while. If you right-click ‘mkchromecast’ and select ‘Volume’, you can adjust the volume on the Google Speaker itself.

Multiple Speakers

The best thing about casting to a Google Speaker is to cast to multiple speakers. From your Google Home app, most likely on your phone or tablet, open ‘Home’.

Tap on the plus sign (+) on the top left of the screen.

On the next screen, select ‘Create Speaker Group’. A list of speakers will be shown. Select all the speakers that you want to add to the new group. The group is what you’ll be selecting from the list in ‘mkchromecast’ to play the music. Select ‘Next’ and give the Group a name and tap ‘Save’.

Now, when you right-click on the ‘mkchromecast’ icon and select ‘Search for Media Streaming Devices’, the new group should appear. Select the Group after it appears. When you cast music, all the speakers in the group should start playing music.

Conclusion

The ability to stream music to your Google Speakers is a great ability to have for a home sound system. To stream a music list normally, you need to subscribe to Pandora, Spotify, YouTube, etc. The ‘mkchromecast’ program lets you have full control over your music without costing you a monthly fee.

Keep this option in mind for when you have a party. Grab a few Google Speakers when they go on sale and set them up in every room to allow you to stream music everywhere.
 


Personally, I have six Google Home Devices. Five are speakers and one is a display/speaker.

NOTE: I also have my ceiling fan, lamp, printer and a black light hooked to Google Home. The printer is plugged into an ‘outdoor heavy-duty’ extension cord that is controlled by Google Home. When I tell Google to turn on the printer, the plug powers on and the printer starts. I can power on the printer from any room.

Blimey!
I’m a bit of a Luddite by comparison. I don’t have any of those kinds of "smart" devices on my network. I just don’t trust them!

Hell, I even keep a sturdy set of nunchucks next to the WiFi printer, in case that ever starts making any suspicious noises, ha ha ha!

Great article though.
My girlfriends kids have a few Google dots and chrome sticks at her place. I’ll have to try connecting to their devices and freaking them out by playing weird noises through them in the middle of the night, ha ha ha!
 
Ah, the perfect use!
 
Late bump, but anyways, found this thread in my attempt to get some smooth app for streaming to Google Chromecast (or Nest Audio speaker) thru' my Raspberry server. I snatched your input and gave it a go:

Code:
gew@raz:~ $ sudo apt install mkchromecast
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  python-colorzero
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  flac lame opus-tools python3-ifaddr python3-protobuf python3-pychromecast python3-zeroconf vorbis-tools
Suggested packages:
  lame-doc libav-tools mkchromecast-pulseaudio mkchromecast-alsa
The following NEW packages will be installed:
  flac lame mkchromecast opus-tools python3-ifaddr python3-protobuf python3-pychromecast python3-zeroconf vorbis-tools
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 2 482 kB of archives.
After this operation, 9 763 kB of additional disk space will be used.
Do you want to continue? [J/n] y
Get:1 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf flac armhf 1.3.2-3+deb10u2 [140 kB]
Get:2 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf lame armhf 3.100-2+b1 [277 kB]
Get:3 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf python3-protobuf armhf 3.6.1.3-2+rpi1 [320 kB]
Get:4 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf python3-ifaddr all 0.1.6-1 [7 452 B]
Get:5 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf python3-zeroconf all 0.21.3-1 [27,7 kB]
Get:6 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf python3-pychromecast all 2.4.0-1 [35,0 kB]
Get:7 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf vorbis-tools armhf 1.4.0-11 [175 kB]
Get:8 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf opus-tools armhf 0.1.10-1 [64,5 kB]
Get:9 http://ftp.acc.umu.se/mirror/raspbian/raspbian buster/main armhf mkchromecast all 0.3.8.1-1 [1 435 kB]
Fetched 2 482 kB in 2s (1 038 kB/s)
Selecting previously unselected package flac.
(Reading database ... 178857 files and directories currently installed.)
Preparing to unpack .../0-flac_1.3.2-3+deb10u2_armhf.deb ...
Unpacking flac (1.3.2-3+deb10u2) ...
Selecting previously unselected package lame.
Preparing to unpack .../1-lame_3.100-2+b1_armhf.deb ...
Unpacking lame (3.100-2+b1) ...
Selecting previously unselected package python3-protobuf.
Preparing to unpack .../2-python3-protobuf_3.6.1.3-2+rpi1_armhf.deb ...
Unpacking python3-protobuf (3.6.1.3-2+rpi1) ...
Selecting previously unselected package python3-ifaddr.
Preparing to unpack .../3-python3-ifaddr_0.1.6-1_all.deb ...
Unpacking python3-ifaddr (0.1.6-1) ...
Selecting previously unselected package python3-zeroconf.
Preparing to unpack .../4-python3-zeroconf_0.21.3-1_all.deb ...
Unpacking python3-zeroconf (0.21.3-1) ...
Selecting previously unselected package python3-pychromecast.
Preparing to unpack .../5-python3-pychromecast_2.4.0-1_all.deb ...
Unpacking python3-pychromecast (2.4.0-1) ...
Selecting previously unselected package vorbis-tools.
Preparing to unpack .../6-vorbis-tools_1.4.0-11_armhf.deb ...
Unpacking vorbis-tools (1.4.0-11) ...
Selecting previously unselected package opus-tools.
Preparing to unpack .../7-opus-tools_0.1.10-1_armhf.deb ...
Unpacking opus-tools (0.1.10-1) ...
Selecting previously unselected package mkchromecast.
Preparing to unpack .../8-mkchromecast_0.3.8.1-1_all.deb ...
Unpacking mkchromecast (0.3.8.1-1) ...
Setting up vorbis-tools (1.4.0-11) ...
Setting up opus-tools (0.1.10-1) ...
Setting up lame (3.100-2+b1) ...
Setting up python3-ifaddr (0.1.6-1) ...
Setting up flac (1.3.2-3+deb10u2) ...
Setting up python3-protobuf (3.6.1.3-2+rpi1) ...
Setting up python3-zeroconf (0.21.3-1) ...
Setting up python3-pychromecast (2.4.0-1) ...
Setting up mkchromecast (0.3.8.1-1) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for gnome-menus (3.31.4-3) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for desktop-file-utils (0.23-4) ...


gew@raz:~ $ mkchromecast
Traceback (most recent call last):
  File "/usr/bin/mkchromecast", line 8, in <module>
    from mkchromecast.cast import *
  File "/usr/share/mkchromecast/mkchromecast/cast.py", line 14, in <module>
    from pychromecast.dial import reboot
ImportError: cannot import name 'reboot' from 'pychromecast.dial' (/home/c/.local/lib/python3.7/site-packages/pychromecast/dial.py)
gew@raz:~ $

As you can see, there is an error! :/

Is this due to mkchromecast not capable of running in command line, only GUI?
 

Members online


Latest posts

Top