-1

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?

Stephan
  • 2,356
  • 16
  • 38

3 Answers3

0

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:

  1. An audio stream is playing on a Sonos speaker (in your example, a TuneIn radio station)
  2. A doorbell press triggers a loadAudioClip API call, which plays a doorbell sound (from a provided stream URL) on the Sonos speaker
  3. 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

  • we are playing doorbell from a playlist in the application using loadplaylist API. Is there any away to get the URL of the doorbell from the playlist.so I can use loadAudioClip API to play a doorbell. thank you – Muhammed Fazil Jul 25 '20 at 06:12
  • Using AudioClip with a custom URL is exactly the feature we are looking for. But currently, audioClip seems not to support groups. The other question is related to the Play:1 customers out there. Will the Play:1 ever support audioClip? – Muhammed Fazil Aug 05 '20 at 04:13
  • Hi @MuhammedFazil - We are planning on supporting audioClip for groups and audioClip on Play:1 in the future. Unfortunately, there is no timeline I can give for when these features will be available. – MarkBronnerSonos Aug 06 '20 at 14:33
0

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

-1

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

Stephan
  • 2,356
  • 16
  • 38