Got Chromecast playback working

My chromecast enabled speaker got here today, and I can use Castbridge inside LMS Volumio plugin to cast to it without a problem, I just had to use transcode to FLAC.

It’s a nice alternative to everyone wanting to use chromecast on Volumio current version.

Hi Pablo,

I’m curious if you can stream to both the chromecast speaker and volumio at the same time? Can you setup a zones in Volumio?

Love the conversation going on here.

Stop posting the same thing several times! Please remove your post and keep only one. TY

Yes, but not inside Volumio. I use iPeng player and then you can play to whichever zone you like. You can even link all of them to play the same thing. But that’s a an iPeng feature.

It’s also a much better player, you can shuffle all your music a lot faster and better than inside Volumio, you can even choose genres and shuffle them or shuffle entire albums.

1 Like

@dresdner353 I’m getting long pauses between tracks (about 5 minutes 20 seconds). Is this expected behavior? mpd2chromecast 1/31/21, Volumio 3.015, Raspberry Pi model B.

That sounds like an issue with Volumio or MPD and the track length. I used to see that on earlier betas but it seemed to just go away on later releases. I suspect the issue is still there now.

Assuming, you installed mpd2chromecast via the github instructions, it’s going to be running in the background and not collecting logs.

So, ssh in as volumio and run the following:

killall python3; python3 mpd2chromecast/

This is trying to kill the running python instance and immediately run the script so we can get it on the console and logging. What you want to end up seeing, is a scrolling status, being updated every second. If it stops outputting after 1-2 seconds, then use the up arrow and repeat the command until you get your console instance of the script running. When you’re done with that mode, just ctrl-C to interrupt and the background script will respawn the python process. If you do this command while something is playing, you should experience a restart of the track and similarly when you interrupt the command.

So when you get this console instance running, something like this should appear (updating every second):

Sun Feb 14 09:08:39 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:39 2021 MPD (pause) vol:33 0:00/4:38 [00%]
Sun Feb 14 09:08:39 2021 Office Google Home (play) vol:33 0:00/4:38 [00%]
Sun Feb 14 09:08:39 2021 Initial cast... Waiting for chromecast elapsed time

Sun Feb 14 09:08:40 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:40 2021 MPD (pause) vol:33 0:00/4:38 [00%]
Sun Feb 14 09:08:40 2021 Office Google Home (play) vol:33 0:01/4:38 [00%]
Sun Feb 14 09:08:40 2021 Initial cast... elapsed time detected.. Unpausing mpd

Sun Feb 14 09:08:41 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:41 2021 MPD (play) vol:33 0:01/4:38 [00%]
Sun Feb 14 09:08:41 2021 Office Google Home (play) vol:33 0:02/4:38 [00%]

Sun Feb 14 09:08:42 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:42 2021 MPD (play) vol:33 0:02/4:38 [00%]
Sun Feb 14 09:08:42 2021 Office Google Home (play) vol:33 0:03/4:38 [01%]

Sun Feb 14 09:08:43 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:43 2021 MPD (play) vol:33 0:03/4:38 [01%]
Sun Feb 14 09:08:43 2021 Office Google Home (play) vol:33 0:04/4:38 [01%]

Sun Feb 14 09:08:44 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:44 2021 MPD (play) vol:33 0:04/4:38 [01%]
Sun Feb 14 09:08:44 2021 Office Google Home (play) vol:33 0:05/4:38 [01%]

Sun Feb 14 09:08:45 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:45 2021 MPD (play) vol:33 0:05/4:38 [01%]
Sun Feb 14 09:08:45 2021 Office Google Home (play) vol:33 0:06/4:38 [02%]

Sun Feb 14 09:08:46 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:46 2021 MPD (play) vol:33 0:06/4:38 [02%]
Sun Feb 14 09:08:46 2021 Office Google Home (play) vol:33 0:07/4:38 [02%]

Sun Feb 14 09:08:47 2021 Current Track:The Alan Parsons Project/Eye In The Sky/Eye In The Sky
Sun Feb 14 09:08:47 2021 MPD (play) vol:33 0:07/4:38 [02%]
Sun Feb 14 09:08:47 2021 Office Google Home (play) vol:33 0:08/4:38 [02%]

Each second, it’s showing what MPD is doing and what the chromecast is doing. Go ahead and play tracks, albums etc.

What I suspect you will find is that once you experience the long track gap occurring again, that it will show the MPD track length as something that is longer than the actual length.

The above example of Eye in the Sky has a track length of 4:38 and its playback is 7 seconds in on MPD (what volumio thinks is playing). When I would get a glitch like this, it might end up saying the track was 8 minutes. Then when the cast device had long since stopped playback, Volumio (via MPD) was still playing it counting up to the wrong length until it changed track and then the script reacted and cast the next track.

So if you can follow this along, let’s see if that is what is the trigger.

Interesting. So after the track ends, mpd restarts it and continues playing; however the Chromecast appears to be idle:

Sun Feb 14 18:01:43 2021 Current Track:White Noise on the River/Rain on the River
Sun Feb 14 18:01:43 2021 MPD (play) vol:15 0:40/2:02 [32%]
Sun Feb 14 18:01:43 2021 SmithCast Audio (play) vol:15 0:00/2:02 [00%]

This continues for about 5:20 at which point I get this:

Sun Feb 14 18:02:17 2021 Current Track:White Noise on the River/Rain on the River
Sun Feb 14 18:02:17 2021 MPD (play) vol:15 1:13/2:02 [59%]
Sun Feb 14 18:02:17 2021 Failed to get chromecast status... 20/20
Sun Feb 14 18:02:17 2021 Detected broken controller after 20 status failures

At this point it looks like it starts over from scratch and playback resumes fairly quickly. So is it disconnecting from the Chromecast when the track ends?

Sorted the issue. A repeating track or the exact same file appearing consecutively in a playlist would cause a failure to cast the next track as the script would not detect an actual “file” change.

The fix was easy as MPD uses a unique ID per played song or stream and this increases each time even for repeated tracks. So I just tweaked it to track that alongside the filename and it now reacts correctly to repeated tracks.

On your end:

cd mpd2chromecast
git pull
killall python3

and you should be sorted.

1 Like

Yep that appears to have done the trick; the track restarts after a couple seconds now. Thanks!

hi, the sound going out from pi-volumio but not from altro-chromecast … can you help me?

Can you run the following on the terminal to volumio:

killall python3; python3 mpd2chromecast/

that will capture output of the script as it running and it may help explain why nothing is streaming to the selected cast device. You can copy and paste in some of the text into this topic

hi man, thanks for reply.

Fri Jun 4 13:53:29 2021 Looking up Chromecast Altro
Fri Jun 4 13:53:29 2021 Getting chromecast device object
Fri Jun 4 13:53:29 2021 Failed to chromecast device object

just for knowledge i’ m on the pi1-b+ Volumiobuster-3.074-2021-05-17-pi.img (fresh install after previous post without any upgrade) and the sound is .mp3 from Media Server.

have a nice day :slight_smile:

edit: i try also an .mp3 from key-usb but i get the same behavior

Looks like an issue with the pychromecast python module. Something was updated there and it’s breaking my code. I’ve just recreated it locally on my end. So I’ll get it going again and advise its sorted.

OK, that was a quick fix.

In your case, the following should fix it…

ssh into the pi and run:
cd mpd2chromecast
git pull

Then try running it manually again:

killall python3; python3 mpd2chromecast/

Hopefully it will work this time and if so, you can Ctrl-C the local run and the script should be restarted in the background.

Greetings. Hopping on to this thread for… reasons :slight_smile:

Say… google discontinued the chromecast audio. Which bums me out / I always hoped this would come to volumio eventually

Would it be an idea to get access to whatever they left is with? Can I inquire to Google devs in your name?

Cheers and thanks for your hard work

It’s not the same thing to compare what I did here and what the Chromecast Audio is.

So to clarify… In Chromecast API terms, there are three roles/apps involved in the streaming:

  1. Controller (controls playback, initiates the streaming etc)
  2. Sender (supplies the data for streaming via URL)
  3. Receiver (the end device that streams the data from the sender URL and plays the audio… i.e chromecast or smart speaker etc)

If you’re using your phone to cast YouTube to a cast-enabled TV or Chromecast, then your phone is the “controller”, YouTube servers are the “sender” and the “receiver” is the TV or attached Chromecast device.

The script I wrote leverages existing Chromecast API modules (pychromecast) in Python and turns Volumio into a Google Cast “Controller” and “Sender”. That then converts local playback of files into “controller” requests to the desired Chromecast and then plays the role of “sender” to stream the target audio file to the receiver.

Google discontinuing their audio-only dongle is thus not related to this. There are a load of normal Chromecasts out there well capable of streaming audio via their HDMI into receivers. There are many AVRs with built-in Chromecast audio support and many active speakers that support this as well. All of these should work fine with my script.

I totally understand that the HDMI-based Chromecasts fall short in not having a desirable SPDIF output for dedicated stereo hardware. I’m also aware that even with HDMI, that they forcefully up/down-sample to 48Khz. But it still possible to deploy a normal Chromecast with a HDMI interceptor and get a SPDIF coax/optical feed off the device. Chromecast audio dongles are also still available on Ebay. Google killed it off because the sales levels were way too low compared to other devices to justify continuing to manufacture it.

There was some hope in the past that Google might add an analog line jack/optical port to a future update to their Nest home mini. Unfortunately that has no signs of happening any time soon.

But the variables are being changed, especially in the last few weeks. With Apple now offering lossless streaming, this will be a good nudge for Spotify, Google and others to do the same and at the same pricing.

Then we might see a reissue of the Chromecast Audio or that SPDIF port option appear in a later issue of the Nest Mini.

Hi folks,
I’ve just released an update to my mpd2chromecast script “plugin” with some improvements:

  • The script now runs via a systemd service (use sudo systemctl to start/stop/enable/disable)
  • It has a first stab at supporting streaming the MPD output stream (works with moOde only and should work for gapless playback). I’m still working on this support in Volumio.

Full instructions here:…/

Quick install guide
To install or upgrade an existing setup on Volumio, you need only do the following:

ssh volumio@volumio.local
curl -s | sudo bash

This will download/install the script and related python modules and start the new mpd2chromecast systemd service. It may take some time to complete.

If it works, then you can browse to http://[your device ip]:8090 and should get a control panel web page like the attached screenshot below. That control panel lets you select a desired Google cast device on your network and should then be able to stream any current playback to that selected device. By setting the cast device to “Disabled”, it will disable the functionality.

Streaming the file vs MPD Output Stream
The 2nd combo box (with play icon) can be used to toggle between two playback modes:

  • Cast file URL (Default)
    This is the default mode which serves the playing track file as a URL to the cast device. The end device will stream the selected file directly and perform all decoding.

  • Cast MPD Output Stream (experimental, not yet working with Volumio)
    This is experimental at present and only working with moOde. I have to dig more into Volumio on the best way to get the MPD output stream enabled. But this approach would let you benefit from any onboard DSP processing in Volumio and also be an approach for gapless playback. Certainly in moOde, I’ve been able to get several albums I have with gapless tracks to stream gapless via the target cast device or group. If you do enable this option on Volumio it just wont work for now.

1 Like

Just the steps to follow if you’d like to try MPD streaming on Volumio for mpd2chromecast:
Install/update mpd2chromecast as described in the previous post.

Then we need to edit the MPD config:

ssh volumio@volumio.local
sudo nano /etc/mpd.conf

scroll down to the Audio Output section and paste the following in as an additional audio_output for MPD:

audio_output {
    type "httpd"
    name "HTTP Server"
    port "8000"
    encoder "flac"
    compression "0"
    tags "yes"
    always_on "yes"

Save the file (Ctrl-X to exit and press y when prompted to confirm save)

Then restart MPD with:
sudo systemctl restart mpd

Then you should be able to select the MPD Output stream in the mpd2chromecast control panel (http://volumio.local:8090) and cast from MPD to your desired cast devices. Gapless playback should now work for you.

Note: This is only a temporary setup because Volumio generates the /etc/mpd.conf file each time audio-related settings are made or Volumio is restarted.

To make the settings more permanent, you would need to make the edits instead to the mpd.conf template

sudo nano /volumio/app/plugins/music_service/mpd/mpd.conf.tmpl

and paste in the same audio_output settings.

Then you should get the same changes permanently propagated to the /etc/mpd.conf on the next audio settings update or the next reboot. Tread carefully here as you could totally mess up your volumio setup especially if you have other plugins etc in use. It might be sensible to take a backup of the /volumio/app/plugins/music_service/mpd/mpd.conf.tmpl file first allowing you to roll back if you mess up things.

First of all, thank you for your continued work on getting Chromecast devices to work with Volumio.

I’m new to both Volumio and Pi, so I might not get all the nuances, but if I understand correctly, it is currently only possible to select cast devices from a web browser?

I would love to be able to select them from the zones and outputs tab inside Volumio, since I mostly control it from the 7" touchscreen and the app. I understand that’s a lot more difficult for you to add, but is it something that might come in future versions?

I’d have to develop a plugin natively on the Volumio stack that would integrate with the UI in that way. I’m not sure at all if its even possible. Worst case, it would be a left menu option that brings you to a page with a drop-down for cast device as opposed to something integrated with the existing multi-room features/icons they have.

But there’s a bit more to consider here. Volumio has paid plans for feature sets beyond the basic free stuff. In among those paid plans are support for streaming in Tidal and several other external services. But Volumio also now have an early beta version of their own native Chromecast support and it only works on the highest paid “Superstar” plan (7 Euro/month or 70 Euro/year).

So it’s not something I really should be trying to do if it competes with a premium feature they are trying to bundle and upsell. So in that regard, you will never see a plugin from me that tries to integrate into the native UI. They have every right to upsell stuff and I have no interest in causing conflicts. I’m happier to stay with the model I took that works well on both Volumio and moOde without getting too specific to either platform.

For ease of access, on any mobile you can bookmark the page and on Android, you can even drop an icon on the home screen that brings you directly to the cast page (http://your-volumio-ip:8090). That makes it pretty easy to work with. I can get to mine real easily and setup the casting or disable it.