thibauts / node-castv2-client

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

Monitoring a cast without taking over it. #61

Closed RickeyWard closed 7 years ago

RickeyWard commented 7 years ago

I can't seem to figure out how I could check the details of what is currently being casted, without first sending media to the tv. I'd like to be able to just get the name of the Program using the chromecasts and see it's volume level and seek position before trying to take over control.

Is that possible with this library?

RickeyWard commented 7 years ago

I can get the Volume using getStatus on the client.

function getDeviceStatus(host) { var client = new Client(); console.log("Connecting to Chromecast"); client.connect(host, function() { client.getStatus(function() { console.log(arguments); }); }); }

Doesn't do everything I wanted, but it does work. Just throw this into the demo and call it instead of ondeviceup.

thibauts commented 7 years ago

Hey ! Try client.getSessions to list the running sessions, then client.join in place of client.launchto join an existing session.

If you're trying to monitor a DefaultMediaReceiver session you're in luck as a class implementing the interface to this app is available. If you need to monitor another app if can be more difficult.

If you're lucky though, the app you're trying to monitor will use the standard media protocol and you'll be able to monitor it using the DefaultMediaReceiver app. Then you can listen to status events on the app, or call getStatus(still on the app) and get the current playing status.

Hope it helps !