Skip to main content
Contributor I
Oct 20, 2023 5:32 PM UTC
Answered

Is there an API call to start playback from a Music Service?

I’m trying to automate Spotify playing music on my Sonos speakers when I scan a NFC tag.

I thought I could use Tasker to automate the necessary API calls...

However, Sonos only supports the OAuth flow “Authorization code”, which makes it impossible to automate the task, since I have to show a webpage to the user for that to work.

Is it possible to authenticate in any non-interactive way (Client credentials) or can I automate the Sonos app somehow? (e.g. Android intent?)

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.
controlav
controlavAnswer
Lead Maestro
Oct 21, 2023 1:42 PM UTC

Sure, AVTransport.SetAVTransportURI is the call you need to make on the Coordinator. The hard part is figuring out the resource and the metadata to get it to work - sniff a call from the controller with Netmon. Buried in those args is the id of the item to play, wrapped in a url that is cracked on the speaker into the required SMAPI calls and the music service endpoint.

At this level you don’t need to auth anything - the players contain the tokens, and this API just requires args.

Author of the leading independent Sonos apps for Android, MacOS, iOS, Windows and Xbox.

1 reply

controlav
controlavAnswer
Lead Maestro
Oct 21, 2023 1:42 PM UTC

Sure, AVTransport.SetAVTransportURI is the call you need to make on the Coordinator. The hard part is figuring out the resource and the metadata to get it to work - sniff a call from the controller with Netmon. Buried in those args is the id of the item to play, wrapped in a url that is cracked on the speaker into the required SMAPI calls and the music service endpoint.

At this level you don’t need to auth anything - the players contain the tokens, and this API just requires args.

Translate
Author of the leading independent Sonos apps for Android, MacOS, iOS, Windows and Xbox.