Closed ChillXXL closed 3 years ago
Media control commands are only supported on the DefaultMediaReceiver app. CC32E753 appears to be the Spotify app. Every app can implement its own command structures, etc., so every individual app would need to be supported individually which is obviously out of scope. The AppId here can really only be used to LAUNCH an application, but not control arbitrary command structures.
Hello i8beef,
Thanks for your fast reply. I tried every possible option, now I know it won't work to control Spotify. I understand that it is out of scope for your project. Thanks anyhow.
I will figure out another way. So far I noticed that a Python script called 'PyChromecast' can controll the chromecast with multiple apps like Spotify. Now a way to implement it in Node Red :-)
While media commands are supposed to be relatively common, the underlying app launch / media load logic can vary wildly for every app. That makes it really hard to support ARBITRARY apps, and would require specific nodes per supported APPID basically. That is, while it could theoretically JOIN an existing session, LAUNCHING a new session of any arbitrary app could be problematic.
That is not to say that this module COULDN'T expose a couple of nodes for some common Cast apps. Off the top of my head, YouTube (not hard), Netflix and other video streaming apps (tough), Plex (some examples), Spotify (having trouble finding examples), Google Music (no examples).
If I undertook that though, I'd basically be rewriting this entire node in order to change the architecture to support shared connections to the cast targets (i.e., maintain a connection to the configured Chromecast 24/7 when node is running, ala the MQTT node, etc.), and genericizing the launch / control capabilities across multiple nodes (one per supported app).
Im not saying I won't do it, in fact I've considered it, tried, and failed / got bored once or twice already... but that is a pretty hefty overhaul.
It took me quite some time to connect all the dots (I am no programmer) but I have got it working; I can control Spotify on my chromecast. (Play, Pause, previous Track, Next Track)
I must say it was quite a investigation to figure it out all the relations and must say I must it still redirects quite a lot between different java-scripts which propably can be improved.
FROM Node-Red: castv2-sender.js to spotify.js ( newly created by myself and part of castv2-client") TO media.js (part of "castv2-client") TO Chromecast
What I did (FYI):
"castv2-client"
castv2-sender.js
Reboot Node Red.
To do: by next or previous track the status of node stays on "sending" (yellow) instead of returning to idle (green). If you have any hints tot solve this that would be great.
Maybe this can help you the possibility for adding control of other apps on the chromecast. And feel free to give me feedback If I could have things different/better :-)
Inspired by: Youtube added control AND PyChromecast
So I just rearchitected for 3.0.0... Adding Spotify, or any other application should now be possible in theory. If you're up for it, I'd take a pull request for it... You would just need to make a lib/SpotifyReceiverAdapter, lib/SpotifyReceiver, and possibly a lib/SpotifyController if there are Spotify specific pieces that are needed (i.e., the extra next/previous track parts that are possibly their own cast namespace?), and then add the necessary parts to castv2-sender.js to allow them to be used (just look for "YouTube" and add similar lines for Spotify.
I wanna say there were Spotify authentication pieces from some example I saw, and if that's the case it might be a tiny bit more involved, but I passed in the parent node in initReceiver in the Adapters specifically to allow pulling "config" information like authentication user / pass...
I added preliminary Spotify architecture pieces... It is not fully implemented, and is largely derived from some of the chromecast python code examples so it still needs dragged over the line. It might connect to existing sessions and control (not play new though) as is...
Adding "Help Wanted" as I don't actually have a Spotify account to work with here. The architecture pieces are pretty much in place, but the actual implementation still needs worked out for the following:
If someone wants this working and is feeling adventurous, here's a few possible other code bases to reference, though it doesn't really look like many of them are complete...
Having a quick look at this. The actual Spotify developer site has some good examples of how to implement #1 and maybe #2 still looking. I have a premium account so I can test as i go.
Hello again,
I just dl your latest release and test the QUEUE_NEXT and QUEUE_PREV while playing spotify and worked great. Thx!
I found problems with some commands and cannot figure out why. The command "GET_CAST_STATUS" works, see below, but if I changed the command to "PAUSE" or "PLAY" it doesn't work and get the "Error: Malformed command" while playing Spotify.
What am I doing wrong? I trying to get play/pause and next/previous control of the chromecast. Can you help me?