i8beef / node-red-contrib-castv2

MIT License
22 stars 14 forks source link

GET_STATUS does not return an object #20

Closed Anjerlaan closed 4 years ago

Anjerlaan commented 4 years ago

Hi,

When I start a internet radio cast on my smart speaker (JBL) and I send a castv2 message to the speaker: Both messages stop the cast but GET_CAST_STATUS is returning an object and GET_STATUS does not return an object, why is this?

i8beef commented 4 years ago

GET_CAST_STATUS gets the status of the chromecast itself. GET_STATUS gets the status of the app that is currently running (DefaultMediaReceiver in this case). If nothing it casting currently, then when it runs it should STAT a DefaultMediaReceiver app, and immediately get the status of the app. I guess if nothing is actually casting to it, it just doesn't return a status object.

Anjerlaan commented 4 years ago

But I wrote that an internet stream was casting andno status object was returned

i8beef commented 4 years ago

Ah got ya. Not sure on that one, Ill have to play with it. My gut says its probably something with the underlying library and how it handles connection closing. If there is an active session on the chromecast, it should JOIN rather than LAUNCH. I expressly do NOT close the session, only on the connection, but maybe there's a more graceful way to disconnect without breaking the stream.

Unfortunately, the underlying library is both fairly old, not really maintained anymore, and has horrendous documentation and very little in the way of "proper use" directions. I considered doing something like a shared connection node behind the scenes that maintains a session connection, but when I played with it it really made connection lifetimes much harder to manage... Im concerned that it would be necessary though (Google has a tendancy to massively over engineer these things) as the library here might have an implicit "close" on closing the connection or something like that for non-media cast commands...

i8beef commented 4 years ago

So running against an actual Google Home, I don't seem to get the same results... I can start a cast, and then use GET_STATUS to get current playing state, while it is playing without stopping the cast. Once its done playing it doesn't return anything because the application is done playing. GET_CAST_STATUS is returning everytime without issue as well... so I'm wondering if you are seeing something specific to your speaker.

ChillXXL commented 4 years ago

I can not inject a appropriate payload to the 'cast v2 sender' node to get a the status output in a debug node.

I want to detect if the chromecast is playing or pausing so that I can make a toggle button in node-red to play or pause the stream.

Are there any (copy-paste) nodered examples around for the 'cast v2 sender' node?

Or can you tell me what I need to do to easy make a inject-node (button), or do I need a different node, and copy-paste the code below (on your example site):

{ host: "1.1.1.1", port: 8009, payload: { type: "VOLUME", volume: 100 // 0 to 100 } }
<<< Thanks in advance.

i8beef commented 4 years ago

Closing as there's been no activity from OP in a while. @ChillXXL the examples are the message structure to send into the node. The easiest way to do so is just doing it from a function node.