Pairing To Sound Zone
To stream music, the SDK must first be paired with a specific sound zone within a Soundtrack location. This is done using a temporary pairing code, generated on demand by Soundtrack. Once paired, a unique Device ID will be returned that can be used when checking for SDK updates later.
For implementation details, please refer to splayer_auth_api-1.h
reference. To try out the pairing process, you’ll first need a Soundtrack Test account provided by us, please contact us if you don’t have one.
Obtaining a Pairing Code
There are two primary methods for getting a pairing code, Redirect and Callback or Manual Entry which is then used to call one of the functions initiate_pair_with_code
or pair_with_code_sync
.
Redirect and Callback (Preferred):
This method provides the smoothest user experience by eliminating manual entry. Your companion application, initiates the pairing and the player gets paired automatically without the user typing a code. This is how it is implemented:
- Your companion application initiates a redirect to the following URL:
https://app.soundtrack.io/connect/generic?redirect={REDIRECT_URL}
. Replace<REDIRECT_URL>
with the URL of your companion application that will handle the callback. This URL must include a redirect parameter that points back to your companion app. - The user logs in to their Soundtrack account and selects the desired sound zone to pair the SDK with.
- Soundtrack redirects the user back to your specified
<REDIRECT_URL>
with the pairing code appended as a query parameter:<REDIRECT_URL>?code=<CODE>
- Your companion application can then extract the
code
parameter and programmatically provide it to the SDK to complete the pairing.
If you wish to simulate this pairing flow, you can run this following example locally:
pairing_code_retrial_example.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
See example_auth.c
in the SDK package for a proof-of-concept using this method.
Important Notes:
- The
generic
endpoint is provided strictly for your initial development/testing work only and will only allow redirects to a localhost address. Once you are finished with testing, we will provide a unique slug to your project with specific allowed redirects. - When using the redirect method, ensure your application can handle URL redirects and retrieve parameters from the callback URL.
- Using this method, it is important to clearly communicate through your applications UI the redirect process to the user to avoid confusion.
Manual Entry:
- The user logs in to their Soundtrack account through the Soundtrack web application using any device.
- The user navigate to the desired sound zone they wish to stream music from and generate a pairing code by selecting
Pair
. - A pairing code will be generated and displayed on the page.
- Your application interface (e.g., on the companion app or a screen on the player itself) must provide a place for the user to type in this code.
- Once entered, your application passes the code to the SDK to complete the pairing.