i8beef / node-red-contrib-castv2

MIT License
22 stars 14 forks source link

QUEUE_NEXT not working #73

Closed AndreS235 closed 2 years ago

AndreS235 commented 2 years ago

Play und Pause works perfect with streams the are startet from youtube-music (on Android)... .but QUEUE_NEXT and _PREV does not work.

i8beef commented 2 years ago

Note that YouTube Music may not be the same thing as YouTube from a media receiver standpoint. When you start a YouTube music stream from your phone do you see your node move to a "joined" status?

If so, when you connect a debug node to the output and capture a payload coming out of it, what is the value of "payload.supportedMediaCommands". It may not be advertising that it supports it.

AndreS235 commented 2 years ago

The node moved to a joined status, it offers some nice informations, but the supportet commands is only 262339, but Play, Pause and Seek work (as i tested by now). I include the full object in the bottom.

I've found this in the code: case "QUEUE_NEXT": // bypass check as workaround of a google issue that does not add // the QUEUE_NEXT bit in supportedMediaCommands for DefaultMediaReceiver // https://issuetracker.google.com/issues/139939455 let bypassCheckNext = node.receiver.session.appId === DefaultMediaReceiver.APP_ID && status.items.length > 1; if (bypassCheckNext || status.supportedMediaCommands & 64) { return node.receiver.queueNextAsync(); } Maybe we need an bypass like the DefaultMediaReceiver?

A "next" command is supportet for nearly every media in the "Home"-App, so i thought it works the same way here.

{"mediaSessionId":2059466729,"playbackRate":1,"supportedMediaCommands":262339,"volume":{"level":0.4300000071525574,"muted":false},"playerState":"PLAYING","customData":{"playerState":1},"currentTime":1.343,"media":{"contentId":"sFZL_1HwfkY","contentType":"x-youtube/video","customData":{"listId":"RDMM","currentIndex":1},"metadata":{"metadataType":3,"title":"No Roots","artist":"Alice Merton","albumName":"No Roots","images":[{"url":"https://lh3.googleusercontent.com/Y8-p0Krw2AdeMn8_EaGfYeeGovcOb1y0PrFznds1Q5iSM28lBQni575c5JUKns5AraboRFBb485HAOU1fg=w544-h544-l90-rj","height":544,"width":544},{"url":"https://lh3.googleusercontent.com/Y8-p0Krw2AdeMn8_EaGfYeeGovcOb1y0PrFznds1Q5iSM28lBQni575c5JUKns5AraboRFBb485HAOU1fg=w302-h302-l90-rj","height":302,"width":302},{"url":"https://lh3.googleusercontent.com/Y8-p0Krw2AdeMn8_EaGfYeeGovcOb1y0PrFznds1Q5iSM28lBQni575c5JUKns5AraboRFBb485HAOU1fg=w180-h180-l90-rj","height":180,"width":180},{"url":"https://lh3.googleusercontent.com/Y8-p0Krw2AdeMn8_EaGfYeeGovcOb1y0PrFznds1Q5iSM28lBQni575c5JUKns5AraboRFBb485HAOU1fg=w120-h120-l90-rj","height":120,"width":120},{"url":"https://lh3.googleusercontent.com/Y8-p0Krw2AdeMn8_EaGfYeeGovcOb1y0PrFznds1Q5iSM28lBQni575c5JUKns5AraboRFBb485HAOU1fg=w60-h60-l90-rj","height":60,"width":60}]},"streamType":"BUFFERED","duration":236}}

i8beef commented 2 years ago

So while its CLAIMING to support that media command, I get a hard error back from it when I try to use it

{
  payload: {
    app: "YouTube",
    type: "QUEUE_NEXT"
  }
}

Nets me an error out of the castv2 library that the target responds with an INVALID_COMMAND. Unfortunately, I believe that means that while its advertising support, it actually doesn't accept a generic QUEUE_NEXT command.

i8beef commented 2 years ago

Closing as this seems like an unsupported issue with the underlying cast targets

ChillXXL commented 1 year ago

There seems to be a solution for youtube music to trigger queue previous and queue next to control the player with a few lines (3?) of code. Can this be implemented?

https://github.com/home-assistant/core/issues/40648#issuecomment-745623226

`diff --git a/pychromecast/controllers/media.py b/pychromecast/controllers/media.py index 6d24472..cc47db4 100644 --- a/pychromecast/controllers/media.py +++ b/pychromecast/controllers/media.py @@ -32,6 +32,7 @@ TYPE_PAUSE = "PAUSE" TYPE_PLAY = "PLAY" TYPE_QUEUE_NEXT = "QUEUE_NEXT" TYPE_QUEUE_PREV = "QUEUE_PREV" +TYPE_QUEUE_UPDATE = "QUEUE_UPDATE" TYPE_SEEK = "SEEK" TYPE_STOP = "STOP"

@@ -430,11 +431,11 @@ class MediaController(BaseController):

 def queue_next(self):
     """ Send the QUEUE_NEXT command. """
i8beef commented 1 year ago

Just pushed an update with that hack... Check back for v4.2.3 which should have the fix in it shortly and see if that works for you!

Edit: Scratch that, GitHub actions is failing to build again. I'm gonna have to troubleshoot build system stuff now. Edit2: Ok try 4.2.4

ChillXXL commented 1 year ago

Yes! Now the commands QUEUE_NEXT (next track) and QUEUE_PREV (previous track) both work with Youtube Music and Spotify. Great work! Thanks for the fast implementation. Have a good one :-)