-
Notifications
You must be signed in to change notification settings - Fork 94
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
Support play/pause on media already playing #93
Comments
Any updates on this? Would be awesome to use! :) |
Hi. AFAIK it is possible, I've used a version of that in one of my projects. The code should be something like this, if I remember correctly. import { Client, DefaultMediaReceiver } from 'castv2-client';
const IP_ADDR = ...;
const client = new Client();
client.on( 'status', status => {
if ( status && status.applications instanceof Array ) {
const app = status.applications.find( app => app.appId === DefaultMediaReceiver.APP_ID );
if ( app != null ) {
client.join( app, DefaultMediaReceiver, ( err, player ) => {
} );
} else {
client.launch( DefaultMediaReceiver, ( err, player ) => {
} );
}
}
} );
client.connect( IP_ADDR ); I wrote this code off the top of my head, so there might be dragons (more like bugs 😄) in there. Let me know if it works for you. |
Thank you @pedromsilvapt - I've tried that code. :) When I run that code, the Spotify casting stops and the Default Media Reciever takes over. The code exits with a |
Hi @EricHier. Yeah, sorry, I assumed you were using the default application, which is why in the find method, I was looking for a session like this One caveat is, I'm not sure the |
Ah okay, I see. The sessions I get with [{ appId: 'CC32E753',
displayName: 'Spotify',
iconUrl:
'https://lh3.googleusercontent.com/HOX9yqNu6y87Chb1lHYqhKVTQW43oFAFFe2ojx94yCLh0yMzgygTrM0RweAexApRWqq6UahgrWYimVgK',
isIdleScreen: false,
launchedFromCloud: false,
namespaces: [ [Object], [Object], [Object], [Object], [Object] ],
sessionId: 'e91fc450-998e-4d1c-b3b6-9cc95c578654',
statusText: 'Casting: I Want To Break Free - Single Remix',
transportId: 'e91fc450-998e-4d1c-b3b6-9cc95c578654' }] Afterwards I tried to run client.join(sessions[0], DefaultMediaReceiver, (err, player) => {
player.pause();
}); and get the Does this mean that the protocol is not the same? Or do I miss something? |
Yes I suppose. That particular error seems in my view to be triggered by the status reponse message, which does not contain the mediaSessionId that the DefaultMediaReceiver needs to call the pause method. I've never worked with the Spotify App, so I can't be of much help with that. Sorry 😢 |
Okay. :) I highly appreciate your help - so awesome! ^^ I am not that experienced with this module and you helped me to get a realistic evaluation of the issue. :) |
Hello,
is it possible to support
play
andpause
command on current playing media without launching a new video?Something like this:
or directly operating on client object (like stop/volume/mute/unmute action):
The text was updated successfully, but these errors were encountered: