thibauts / node-castv2-client

A Chromecast client based on the new (CASTV2) protocol
MIT License
646 stars 92 forks source link

No media callbacks occurring #64

Open jpetrocik opened 7 years ago

jpetrocik commented 7 years ago

I don't know if this a general issue or caused by the receiver applications I'm using, i.e. Youtube and Crackle, Netflix, Hulu.

When I send a pause, play, stop request the message returned doesn't contain the requestId and hence never triggers the callback.

Below are the sent and received messages:

castv2 send message: protocolVersion=0 sourceId=client-707282 destinationId=ea6126bb-5cd7-4d38-a844-03460f4d35a2 namespace=urn:x-cast:com.google.cast.media data={"type":"PAUSE","mediaSessionId":1927979685,"requestId":2}

castv2 recv message: protocolVersion=0 sourceId=ea6126bb-5cd7-4d38-a844-03460f4d35a2 destinationId=* namespace=urn:x-cast:com.google.cast.media data={"type":"MEDIA_STATUS","status":[{"mediaSessionId":1927979685,"playbackRate":1,"supportedMediaCommands":3,"volume":{"level":0.009999997913837433,"muted":false},"playerState":"PAUSED","customData":{"playerState":2},"currentTime":8.384}]}

In request-response.js the requestId is checked against the incoming message before calling the callback.

if(response.requestId === requestId) {
  self.removeListener('message', onmessage);

Any thoughts about how to trigger the callback in this situation?

germasch commented 7 years ago

I'm also seeing the same problem with the Youtube and GoogleMusic apps, and I'm being kinda annoyed by it. FWIW, it works correctly with the DefaultMediaReceiver.

I guess the only workaround I can think of is to listen to the status messages and react once I see that the status has changed (e.g., from PLAYING -> PAUSED), and call a callback then.

I find it kinda odd, though, that messages don't get acknowledged as they're supposed to. I suppose the official interfaces probably don't care much (press the pause button -> send pause; get a status with state "PAUSED" -> show pause status), as they don't really care what caused the status change, they just show whatever the latest status is.