[PLUGIN] YouTube Cast Receiver

After update to 20210620-2 (and volumio 3.074) it seems to work in ~10% cases.

Most of the time it’s still “connecting with volumio” and on the logs I see

[yt-cast-receiver.YouTubeApp] stop() ignored - called with different pid.
[yt-cast-receiver.YouTubeApp] Launching...
[yt-cast-receiver.YouTubeApp] Generated screen Id: 14mfjd52mmrdfqbc3ach9jq5kc
[yt-cast-receiver.YouTubeApp] Obtained lounge token: AGdO5p-YS_eaing09eTTzzpkt9cbPfPGE9RJNySvOd0yP343QoBPe6yvRtCCc4-4cGw6Q9sq0gXQKmioEY2Af4tlugkXPwV-oTd5eiQsw9TAB-6_iRzdztI
[yt-cast-receiver.YouTubeApp] Initiate binding...
[yt-cast-receiver.YouTubeApp] Processing initial bind data...
[yt-cast-receiver.YouTubeApp] Command #0 - c received with the following data:
[ 'CA0A6B2FE6AFEE82', '', 8 ]
[yt-cast-receiver.YouTubeApp] Setting SID to CA0A6B2FE6AFEE82
[yt-cast-receiver.YouTubeApp] Command #1 - S received with the following data (gsessionid):
HzKMtrrbkHXmqS2GXjxLiwDvRhggQVEy
[yt-cast-receiver.YouTubeApp] Command #2 - loungeStatus received but not going to be handled. Skipping...
Unhandled data:
{
  devices: '[{"app":"yt-cast-receiver","capabilities":"que,atp,mus","clientName":"unknown","experiments":"","name":"YouTube Cast Receiver","id":"c8277ac4-ke86-4f8b-8fe2-1236bef43397","type":"LOUNGE_SCREEN","hasCc":"true","receiverIdentityMatchStatus":"IS_RECEIVER"}]',
  connectionEventDetails: '{"deviceId":"c8277ac4-ke86-4f8b-8fe2-1236bef43397"}'
}
[yt-cast-receiver.YouTubeApp] Command #3 - getNowPlaying received. Report 'now playing'...
[yt-cast-receiver.YouTubeApp] Posting bind data:
{ count: '1', ofs: '1', req0__sc: 'noop' }
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 1)
[yt-cast-receiver.YouTubeApp] Registering pairing code with the following data:
URLSearchParams {
  'access_type' => 'permanent',
  'app' => 'yt-cast-receiver',
  'pairing_code' => '0e33658a-14a9-42ed-9d5d-c05a0ca5090e',
  'screen_id' => '14mfjd52mmrdfqbc3ach9jq5kc',
  'screen_name' => 'YouTube Cast Receiver' }
[yt-cast-receiver.YouTubeApp] Registered pairing code: 0e33658a-14a9-42ed-9d5d-c05a0ca5090e
[yt-cast-receiver.CommandListener] Started
[yt-cast-receiver.CommandListener] Listening to: https://www.youtube.com/api/lounge/bc/bind?AID=3&CI=0&CVER=1&RID=rpc&SID=CA0A6B2FE6AFEE82&TYPE=xmlhttp&VER=8&app=yt-cast-receiver&capabilities=que%2Catp%2Cmus&device=LOUNGE_SCREEN&gsessionid=HzKMtrrbkHXmqS2GXjxLiwDvRhggQVEy&id=c8277ac4-ke86-4f8b-8fe2-1236bef43397&loungeIdToken=AGdO5p-YS_eaing09eTTzzpkt9cbPfPGE9RJNySvOd0yP343QoBPe6yvRtCCc4-4cGw6Q9sq0gXQKmioEY2Af4tlugkXPwV-oTd5eiQsw9TAB-6_iRzdztI&mdxVersion=2&name=YouTube%20Cast%20Receiver&t=1&theme=cl&v=2&zx=xxxxxxxxxxxx
[yt-cast-receiver.YouTubeApp] Launched
dial: returning pid 10622eba-75ad-42b3-bf60-6d8206678569
[yt-cast-receiver.YouTubeApp] Command #5 - loungeStatus received but not going to be handled. Skipping...
Unhandled data:
{
  devices: '[{"app":"yt-cast-receiver","capabilities":"que,atp,mus","clientName":"unknown","experiments":"","name":"YouTube Cast Receiver","id":"c8277ac4-ke86-4f8b-8fe2-1236bef43397","type":"LOUNGE_SCREEN","hasCc":"true","receiverIdentityMatchStatus":"IS_RECEIVER"},{"app":"youtube-desktop","capabilities":"que,mus","clientName":"web","experiments":"","userAvatarUri":"https://yt3.ggpht.com/yti/ANoDKi57LF-NNrV8y4wTjR4NtOzILudUPtzZq25KDg\\u003ds240","type":"REMOTE_CONTROL","localChannelEncryptionKey":"hVJZYZ9qzjwRoaNThPTL3LklYCgKGtMvaXI8mIOt2gY","pairingType":"unknown","name":"Desktop","obfuscatedGaiaId":"107185610102114055140","id":"ea29dced-9e96-4687-adda-70502b371149","user":"Piotr","receiverIdentityMatchStatus":"DOES_NOT_MATCH_RECEIVER"}]',
  connectionEventDetails: '{"ui":"true","hasInitialPlayback":"true","deviceId":"ea29dced-9e96-4687-adda-70502b371149"}'
}
[yt-cast-receiver.YouTubeApp] Command #6 - remoteConnected received with the following client data:
{
  app: 'youtube-desktop',
  pairingType: 'unknown',
  capabilities: 'que,mus',
  ui: 'true',
  clientName: 'web',
  experiments: '',
  name: 'Desktop',
  id: 'ea29dced-9e96-4687-adda-70502b371149',
  type: 'REMOTE_CONTROL',
  device: '{"app":"youtube-desktop","pairingType":"unknown","capabilities":"que,mus","clientName":"web","experiments":"","name":"Desktop","id":"ea29dced-9e96-4687-adda-70502b371149","type":"REMOTE_CONTROL","receiverIdentityMatchStatus":"DOES_NOT_MATCH_RECEIVER"}',
  receiverIdentityMatchStatus: 'DOES_NOT_MATCH_RECEIVER'
}
[yt-cast-receiver.YouTubeApp] Client does not have autoplay capability. Autoplay support disabled.
[yt-cast-receiver.YouTubeApp] Posting bind data:
{
  count: '1',
  ofs: '2',
  req0__sc: 'onAutoplayModeChanged',
  req0_autoplayMode: 'UNSUPPORTED'
}
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 2)
[yt-cast-receiver.YouTubeApp] Refresh autoplay Up Next
[yt-cast-receiver.YouTubeApp] Posting bind data:
{ count: '1', ofs: '3', req0__sc: 'autoplayUpNext' }
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 3)
info: [ytcr] ***** Connected *****
info: CoreCommandRouter::getUIConfigOnPlugin
[yt-cast-receiver.YouTubeApp] Command #7 - setPlaylist received with the following data:
{
  listId: 'RQZyz9pzbWk-xEHDAjaLfNz83csUU',
  currentTime: '11',
  ctt: 'APmki7QWdSajgT1hr8uHv2YT6nOKJnaxAmPD69sLQ0L6wfniEhVcW6SqWCSKjAx1gjYhpjVdpWWRwv0fmHiDi8K4J2zWw3uaBAAejSsC2Wb9Et-a_OPUwNkeaX0jP7MYBob7qxyVGvEc',
  eventDetails: '{"eventType":"PLAYLIST_SET","userAvatarUri":"https://yt3.ggpht.com/yti/ANoDKi57LF-NNrV8y4wTjR4NtOzILudUPtzZq25KDg\\u003ds240","user":"Piotr","videoIds":["cRlV0DGOVsM"]}',
  sourceDeviceType: 'REMOTE_CONTROL',
  clickTrackingParams: 'CAAQu2kiEwjq2aq9sqzxAhUEHbIKHWmqBa4=',
  videoId: 'cRlV0DGOVsM',
  videoIds: 'cRlV0DGOVsM',
  currentIndex: '0'
}
[yt-cast-receiver.YouTubeApp] Requesting player to play video ID cRlV0DGOVsM at position 11s
[yt-cast-receiver.YouTubeApp] Reporting change in player state...
info: CoreCommandRouter::volumioGetState
[MPDPlayer] Play cRlV0DGOVsM at position 11s
[MPDPlayer] is asleep - returning stopped status
[yt-cast-receiver.YouTubeApp] Posting bind data:
{
  count: '1',
  ofs: '4',
  req0__sc: 'onStateChange',
  req0_currentTime: '0',
  req0_duration: '0',
  req0_cpn: 'foo',
  req0_loadedTime: '0',
  req0_state: '3',
  req0_seekableStartTime: '0',
  req0_seekableEndTime: '0'
}
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 4)
[MPDPlayer] An error occurred while loading track:
MinigetError: Status code: 404
    at ClientRequest. (/data/plugins/music_service/ytcr/node_modules/miniget/dist/index.js:210:27)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:315:20)
    at HTTPParser.parserOnIncomingClient (_http_client.js:641:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
    at HTTPParser.execute ()
    at TLSSocket.socketOnData (_http_client.js:509:22)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
  statusCode: 404
}
Error: Status code: 404
    at ClientRequest. (/data/plugins/music_service/ytcr/node_modules/miniget/dist/index.js:210:27)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:315:20)
    at HTTPParser.parserOnIncomingClient (_http_client.js:641:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
    at HTTPParser.execute ()
    at TLSSocket.socketOnData (_http_client.js:509:22)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
[yt-cast-receiver.YouTubeApp] Command #8 - getVolume received. Reporting volume...
[yt-cast-receiver.YouTubeApp] Posting bind data:
{
  count: '1',
  ofs: '5',
  req0__sc: 'onVolumeChanged',
  req0_volume: '0',
  req0_muted: 'false'
}
info: Ignoring MPD Status Update
info: Ignoring MPD Status Update
error: Upnp client error: Error: This socket has been ended by the other party
[MPDPlayer.MPDEventListener] Event received for subsystem 'playlist'
[MPDPlayer.MPDEventListener] Calling handler.handle()...
[MPDPlayer.MPDEventHandler] Number of callbacks for subsystem playlist: 0
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 5)
[yt-cast-receiver.YouTubeApp] Command #9 - getSubtitlesTrack received but not going to be handled. Skipping...
[yt-cast-receiver.YouTubeApp] Keeping alive...
[yt-cast-receiver.YouTubeApp] Posting bind data:
{
  count: '1',
  ofs: '6',
  req0__sc: 'nowPlaying',
  req0_currentTime: '0',
  req0_duration: '0',
  req0_cpn: 'foo',
  req0_loadedTime: '0',
  req0_state: '3',
  req0_seekableStartTime: '0',
  req0_seekableEndTime: '0',
  req0_listId: 'RQZyz9pzbWk-xEHDAjaLfNz83csUU',
  req0_videoId: 'cRlV0DGOVsM',
  req0_currentIndex: '0'
}
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 6)
[yt-cast-receiver.YouTubeApp] Keeping alive...
[yt-cast-receiver.YouTubeApp] Posting bind data:
{
  count: '1',
  ofs: '7',
  req0__sc: 'nowPlaying',
  req0_currentTime: '0',
  req0_duration: '0',
  req0_cpn: 'foo',
  req0_loadedTime: '0',
  req0_state: '3',
  req0_seekableStartTime: '0',
  req0_seekableEndTime: '0',
  req0_listId: 'RQZyz9pzbWk-xEHDAjaLfNz83csUU',
  req0_videoId: 'cRlV0DGOVsM',
  req0_currentIndex: '0'
}
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 7)
[yt-cast-receiver.YouTubeApp] Keeping alive...
[yt-cast-receiver.YouTubeApp] Posting bind data:
{
  count: '1',
  ofs: '8',
  req0__sc: 'nowPlaying',
  req0_currentTime: '0',
  req0_duration: '0',
  req0_cpn: 'foo',
  req0_loadedTime: '0',
  req0_state: '3',
  req0_seekableStartTime: '0',
  req0_seekableEndTime: '0',
  req0_listId: 'RQZyz9pzbWk-xEHDAjaLfNz83csUU',
  req0_videoId: 'cRlV0DGOVsM',
  req0_currentIndex: '0'
}
[yt-cast-receiver.YouTubeApp] postBind() completed (ofs: 8)

and of course youtube is not played…

@patrickkfkan
i seems it went bad again.
mine gave a 404 error… network fault.

strange because when you said test it …it worked.

Hi; I have a problem with the plugin (i on a rpi4 and i update mpd)

I got these error : ReferenceError: URL is not defined

The YouTube2 and YouTube Cast Receiver plugins are broken at the moment. More info here:

@flutty, this error does appear on my Volumio 2.x too when I reinstalled the plugin. I initially thought I had implemented some compatibility fix for 2.x but apparently this was not the case. Anyway, please wait for an update which I’ll announce here when available.

2 Likes

Like the YouTube2 plugin, the YouTube Cast Receiver should now work on both Volumio 2 and 3. Please update it through the instructions on the Github page and report any issues.

I have also added a “Bind to Network Interface” option which you can find in the plugin settings. If you have multiple active network interfaces such as LAN and WiFi and have trouble connecting to the YouTube Cast Receiver, you can try binding to a single interface instead of “All”. Just make sure that the interface you are binding to belongs to the same network as the device you are casting from.

both youtube2 and this working fine after the update. thanks @patrickkfkan

3.074 running good
3.010 needs a reboot to work.

great work again patrick :point_left: :crazy_face: :+1:

@patrickkfkan Thanks for this - this was one of the last things I need to get my folks using their device more often!

Works great on Bullseye (mpd 0.22.6) as well :slight_smile:

@ashthespy when do you release the bulleye after you gave it over
it went down down down… it’s getting very unresponsive and it’s not released yet

Let Debian and Raspberry release something first, these are just testing images to see how much effort it would take Volumio to work on Bullseye :wink:

Now back to the topic of this plugin :slight_smile:

– The times seem to be out of sync, resulting in the YT client showing a much faster playbar, and skipping to the next track while the current one is still playing?
So with the debug mode on, and more verbose logs, this seems to go away. :expressionless: I will dig deeper later…

– I also see this error - is it expected or?

 [yt-cast-receiver.autoplay] An error occurred while fetching mix playlist for video Id HT4MgAtBbJA: Error: Unable to find JSON!

Cheers!

PS: would it be possible to do some pre-fetching for a playlists? While gaplass is a bit of an ask, there is a good 1s delay b/w songs now, that I don’t believe is to do with my bandwidth…

did you update the YT-Cast?

Hi @ashthespy ,

Your Spotify Connect plugin helped me a lot in writing this :laughing:

I did notice the ‘out of sync’ issue, but I thought this was one of the Volumio quirks that manifests itself on occasion. In my case, the YT app is always showing the correct time and it is in fact Volumio that is showing the wrong (slower) time. If you change the volume in Volumio UI, you should see the times re-synced again. Could you confirm this behavior and also whether playback really skips to the next track while the current one is still playing?

For the video ID you gave, I had this in my log:

Jul 17 01:59:25 volumio-pi volumio[1037]: [yt-cast-receiver.YouTubeApp] Updating autoplay Up Next...
Jul 17 01:59:25 volumio-pi volumio[1037]: [yt-cast-receiver.autoplay] getUpNextVideoId(): Trying to obtain from mix playlist
Jul 17 01:59:25 volumio-pi volumio[1037]: [yt-cast-receiver.autoplay] Fetching mix playlist for video Id HT4MgAtBbJA
Jul 17 01:59:27 volumio-pi volumio[1037]: [yt-cast-receiver.autoplay] Up next video:
Jul 17 01:59:27 volumio-pi volumio[1037]: { id: 'Kp7eSUU9oy8',
Jul 17 01:59:27 volumio-pi volumio[1037]: title: 'Childish Gambino - Redbone (Official Audio)',
Jul 17 01:59:27 volumio-pi volumio[1037]: author:
Jul 17 01:59:27 volumio-pi volumio[1037]: { name: 'Donald Glover',
...

So in my case, I did get a Mix playlist for the same video. I would have to look further into this (might need your help in finding the cause).

When I have time, I’ll see what can be done about this. Do you know if Volumio will call the plugin’s prefetch function when the current track is about to end, or do I have to monitor this myself? To be honest, I try to avoid going through Volumio’s code whenever possible (especially that statemachine)…

Glad it helps, I fought a lot with statemachine as well, so I feel your pain. I am in a similar boat these days, Volumio’s API really needs some love.

I will dig a round more and post some more concrete logs/debugging soon.
Thanks again for this!

Love this plugin, works super well with youtube directly. Any way of having this endpoint available in the google home app so that we can add volumio to a home’s speaker group for playback?

Thanks!

If I understand correctly, you would like Volumio to show up as an output device within the Google Home ecosystem. If that’s what you mean, then I’m afraid it’s not possible.

Ah, yeah, that’s what I meant. Too bad! thx anyways :slight_smile:

Doesn’t work on YouTube Music.
support plz …

on Volumiobuster-3.152-2021-11-23-pi.img

I don’t think it can be done, as YouTube Music uses a different cast protocol that requires authentication by Google…

What resolution is youtube casting at? Is it really 32bit/48hz ?

Screenshot 2021-12-11 5.47.46 PM

This information is provided by MPD. 48kHz should be correct, but “32-bit” should be interpreted as 32-bit floating point. Bitrate on the other hand is mostly 160kbps.

1 Like