Sonos Cloud API Queues - sonos

I want to develop a Sonos Controller that is capable of:
Playing a playlist or album now, or next (after currently playing song) or by appending it to the end of the queue.
However I can't see a way to control how the playlist is added to a queue. The documentation at https://developer.sonos.com/reference/control-api/playlists/loadplaylist/ doesn't suggest that it is possible,but there is a reference to the queue in the description for the shuffle playmode "Play the tracks in the queue in a randomly shuffled order."
There is documentation for "Cloud Queues" but this seems to be targeted at Music Services.
Is it possible to create a Cloud Queue that just holds references to tracks in other services?
Not that I would really want to implement that, I would rather just access the queue that is on the players.

The Sonos Control API does not currently allow for direct access to the player queue. Third party integrations can get content on to the queue via the playlists and favorites namespaces, but they can't touch the queue directly.
As you noted, the Cloud Queue API is intended for Content Partners. It is not directly possible to reference third party content in personal CQs, there are authentication issues involved.

This squares with my user experience of the Sonos queue being very basic and unintelligent. There have been a number of times I've been forced to clear the queue and start over, rather than being able to reorder items, etc. FWIW, the closest thing I've seen in their documentation to what it sounds like you're looking for, is under a different API. Sonos Music API > reorderContainer as documented here: https://developer.sonos.com/reference/sonos-music-api/reordercontainer/
I don't see any similar functionality documented in the Sonos Cloud Queue API. With regard to random order, I believe that's on playback, not anything that modifies the queue.

Related

SONOS API Question: AudioClip can you queue up more than one clip?

If I try to load back 2 back clips, it appears that they interupt each other. The documentation seems to suggest that by using audioClipStatus you get an array of audioClips, suggesting they can be queued.
Anyone has any info on this?
Secondly, I like the "Chime" audioclip and would love to be able to concatenate an audioClip preceeded by a Chime to announce an announcement. It would be great if there was an option like that.
One suggestion to the Sonos Dev team, perhaps allow the loadAudioClip to have an array of clips as opposed to a single clip.
Any reaction from the Sonos Dev team?

Assigning webhooks to Firebase Messaging "subscribe to topic" event

In my current project I am using the Kreait Firebase PHP SDK to send out push notifications to Android & iOS devices that have subscribed to notifications on named topics. No issues thus far. However, rather than have fixed topic names I would now like to generate topic names based on the current "condition" of the connecting device. The condition could, for example, be a geographic location.
This is not too difficult either and I have modified my app to handle this. However, in order to put the ability to have such autogenerated topics to use I need to know the topic names on my server so I can send out targeted messages via Kreait. I find Google's Firebase documentation a bit dense at times and have not been able to establish whether it is possible to assign webhooks that get called by Firebase whenever a SubscribeToTopic, UnsubscribeFromTopic event occurs.
A simple question - does FCM even offer anything like this capability? If so, any pointers to the relevant documentation would be much appreciated.
There is no public API to get a list of topic names from Firebase, nor is there a way to hook into the subscription mechanism.
Your best bet is to simply make two calls when a user subscribes to a topic: one to Firebase, and one to your own backend API that keeps a list of active topics/conditions.

How To Play Specified Google Play Music Resources (Albums) via Sonos API

I have ~300 vinyl records which I want to attach RFID tags to so I can place one on an RFID reader and trigger playback of the album on my home Sonos (using Google Play Music).
Is there a way to load a specified resource from a service into a group? I was able to follow through the Postman tutorial, and was maybe thinking that I could set up each album as a Sonos Favorite and load that, but I'm looking around and see that there is a (very low) limit on how many favorites you can have, so this doesn't seem like a workable solution anymore. I've been digging around the APIs and can't quite find what I'm looking for in the Control API.
Ideally I'd have each RFID tag contain something along the lines of artist name, album name, and some Google-Play-Music-specific album ID, which I can use to load the album into a fixed Sonos Group queue. If there's a better approach, however, I'm also all ears.
The Sonos API doesn't offer a way to load and play content from another service (other than commands in the favorites namespace) unless that service provides an interface to get the Sonos IDs without authentication. An alternative is to host your own files and build a SMAPI server or use a mediaUrl to your audio file in the track.
See the SMAPI sample server and Tracks in the cloud queue in Play audio (cloud queue) for details.

Using pre-recorded audio instead of text-to-speech along with Watson Conversation bot

I built a conversation bot with text-to-speech, but no matter how well I tune it, the voice sounds robotic.
I think it would be simpler to have the conversation bot pick a pre-recorded audio and stream it back to the user.
Does anyone see issues with this?
Is there already an example of this so I don't reinvent the wheel?
This functionality needs to be implemented on the client side of the application. Watson Conversation Service can return a text answer and for example an index of the audio record you want to play.
This index then needs to be picked up by the client application communicating with Watson Conversation Service (e.g. a web page in node.js) and the audio record can be played to the user.
As for some examples...in Conversation Service docs there are links to github projects that integrate Watson Conversation Service with node.js web applications - these can be extended by adding the audio records and functionality that will play those records to the user.

Implementing Facebook's Like feature using Google Cloud Messaging

I have a use case to implement a 'like' feature for messages using GCM. One approach that comes to mind is to make each post a 'topic' and then send all likes on a post as a separate GCM message on that topic.
However, in order to achieve this, the client has to register for each topic corresponding to the post that it has loaded on the UI in real time. This brings me to the following questions:
This is approach right?
How long will it take for a client's subscription to a topic to reflect at GCM's end? Same for unsubscription?
Can I get a list of all subscribers to a given topic?