Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get information about played movie/song #74

Open
pouniok opened this issue Aug 27, 2017 · 1 comment
Open

How to get information about played movie/song #74

pouniok opened this issue Aug 27, 2017 · 1 comment

Comments

@pouniok
Copy link

pouniok commented Aug 27, 2017

Hello,

Is there a way to get a status update when something is streamed on the Chromecast, like the Title, duration, current position in the movie and a snapshot or background picture ?

I can't find any clue on how to do that, everything seems oriented on sending information to the chromecast :)

Thanks !

@pedromsilvapt
Copy link

Have you tried the player.getStatus() method? Note that this method works only when using the DefaultMediaReceiver, and afaik, you need to at least know what app is receiving to use it.

NOTE I'm using the async/await syntax for clarity, but if you want I can write it using callbacks either way.

// Small helper function to use promises and async/await instead of callbacks
const co = ( c : any, b : string ) => util.promisify( c[ b ].bind( c ) );

let client = new Client();

await co( client, 'connect' )( CHROMECAST_IP_ADDRESS );
    
const apps = await co( client, 'getStatus' )();

const sessionId : string = apps.applications[ 0 ];
    
const player = await co( client, 'join' )( sessionId, DefaultMediaReceiver );

const status = await co( player, 'getStatus' )();

console.log( status );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants