Play a specific track of a playlist in a Sonos Group - sonos

I would like to load a playlist to a Sonos Group and play a specific track from this playlist.
Using this api I can load a playlist and play the first track
POST /groups/{groupId}/playlists
{
"playlistId" : "1",
"playOnCompletion" : true,
"action" : "REPLACE"
}
but how can I play a specific track of this playlist?

Related

How do I get the video category associated with a youtube video from the video url?

I'm wokring on a personal project where I need to get the video category associated with a youtube video from the video url but I can't seem to find a solution. The Youtube API gives me a list of video categories but not assocaited with any specific video.
My code is basically scratched.

How to get playing radio station url using sonos API

We are using Sonos API for controlling Sonos. We need to play a radio station on a speaker.we are using playbackMetadata API for getting the information about the radio station and we get a response as below
{
"container" : {
"type" : "station",
"service" : {
"id" : "254",
"name" : "TuneIn"
},
"name" : "Radio Bern1",
"id" : {
"accountId" : "sn_0",
"objectId" : "s15452",
"serviceId" : "254"
}
}
}
we need to play this radio station again after a doorbell is played in the same speaker. for that, we need the URL of the radio station to play using loadAudioClip API in Sonos document. Is there any other API that we can use?
Am I correct in understanding that you are trying to resume the existing music on a device after a doorbell sound is played?
If so, then the best way to accomplish this is to use the loadAudioClip API for the doorbell sound: https://developer.sonos.com/reference/control-api/audioclip/loadaudioclip/
A solution using the loadAudioClip API would work like this:
An audio stream is playing on a Sonos speaker (in your example, a TuneIn radio station)
A doorbell press triggers a loadAudioClip API call, which plays a doorbell sound (from a provided stream URL) on the Sonos speaker
When the audio clip is finished playing, the original stream (a TuneIn station in this example) will automatically resume playing.
In summary, you want to use loadAudioClip for the doorbell sound, and it will automatically resume any music stream that was already playing.
Please let me know if this doesn't solve your problem.
Thanks!
-Mark
There is no way to get a direct stream link to a playlist item. You have two options to solve this issue using the loadAudioClip API: https://developer.sonos.com/reference/control-api/audioclip/loadaudioclip/
Option 1 - utilize the default CHIME sound that is available as part of the loadAudioClip API. After the CHIME plays, any music that was playing before will resume. Using this default sound is documented in the link provided above.
Option 2 - if you want to play a specific, custom sound clip, you will need to provide your own streamUrl to this sound clip. An example of this is also provided in the documentation link above.
I would suggest starting with Option 1 above to get your application working with the default CHIME clip. If you have a need to use a custom sound, move on to option 2 once you have your custom audio clip available via a streamUrl.
Hope that helps!
Thanks,
Mark
I'm not sure it the cloud api also supports actual urls, but in my sonos library we are generating the TuneIn url with only the information you've provided.
x-sonosapi-stream:{container.id.objectId}?sid={contianer.id.serviceId}&flags=8224&sn=0
or with your data:
x-sonosapi-stream:s15452?sid=254&flags=8224&sn=0

Know if a new video is added in youtube api

Hi how can I check via Youtube api if a new video is added to a playlist ? I want to implements push notifications on 3 playlists for example and whenever a new video is added to playlist 1, then the user will receive a new video.
Thanks !

YouTube Data API video insert/update - setting 'Game title'

The YouTube Data API v3 functions Video.insert and Video.update do not contain an option to set the "Game title" as you can when uploading / updating a video in the web UI:
This is only available if the category is set to Gaming.
Edit: To clarify, I do not wish to set the Video Title. This input is used to identify the Game that is being played in the uploaded video and is displayed under the video description.
Is there an API endpoint to set this Game title? Or do I have to POST to https://www.youtube.com/metadata_ajax?action_edit_video=1 like the web UI does?
The Youtube Data API does not have this implemented at this time of writing. And nether we are able to Get the game title as well.

Soundcloud Live Comment Stream

I am working on an app and would like to display all the comments for a given Soundcloud track in real time. We have created a custom html5 audio player and it is not the format of the standard embedabble soundcloud player. The comments should show up in a given space and follow the progress of the song. It would display the comment with a timestamp of "5 seconds" when the song has played for 5 seconds, etc.
Currently we have only found that you must make a separate API call for each new comment.
The custom player from SoundCloud doesn't support this at the moment.
But if you're building a player using the SC.stream function of the SoundCloud JS SDK you can use the ontimedcomments options:
SC.stream("/tracks", {
autoPlay: true,
ontimedcomments: function(comments){
console.log("First Comment at this timestamp", comments[0].body);
}
});
The only downside with this is that you have to build the player UI yourself.
There are some more examples in this post: http://developers.soundcloud.com/blog/rich-media-using-timed-comments