Getting Started
This section helps you get up and running with the Soundtrack SDK, guiding you through building a simple music player that connects to Soundtrack.
The SDK provides C header files, exposing a modular API known as the SPlayer API. It allows you to:
- Play music from the Soundtrack service
- Authenticate
- Access track metadata (artist, album, track position)
- Audio interface with your platforms audio output
- Playback control (play, pause, skip, volume)
- Browse the user accounts music library for playlist and schedules and play them.
- Retrieve errors.
At its core, the SDK delivers raw PCM audio samples, but audio output implementations for common platforms (e.g., ALSA, CoreAudio) are included to help you connect to your platforms audio backend. For implementing your own audio output, please refer to the Audio Callbacks section.
The actual player logic is implemented in a shared library (built by Soundtrack), and you link against it from your application. Since the provided library is precompiled using a toolchain you provide, API updates can be made without needing to recompile on your end.
SDK Overview
Once you've downloaded and unpacked the SDK, you'll see the following structure:
splayerapi-v5/
├── include/ # C header files for API modules
│ ├── audio_output_callbacks.h # Allocates platform audio callbacks struct
│ └── splayerapi/
│ ├── splayer_audio_api-3.h # Audio output API
│ ├── splayer_auth_api-1.h # Authentication API
│ ├── splayer_controls_api-3.h # Playback control API
│ ├── splayer_library_api-1.h # Users music library API
│ ├── splayer_metadata_api-4.h # Track metadata API
│ ├── splayer_troubles_api-2.h # Troubleshooting & diagnostics API
│ └── splayerapi-5.h # Core SDK entry point
├── lib/ # Precompiled shared libraries
├── reference-app/ # Reference app source, see the Reference App page
├── src/ # Audio output implementations, mock libraries and a local provisioning server
├── CMakeLists.txt # CMake configuration for building the mock libraries
└── changelist.md # SDK changelog
Environment Setup
We’ll use CMake to build a minimal example. You can use any build system you prefer, but CMake is simple and cross-platform.
Create a workspace directory (e.g. example-player/) and place the unpacked splayerapi-v5/ SDK inside it. Create a
CMakeLists.txt file with the following content:
| CmakeLists.txt | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Example Player
Using the CMakeLists.txt file created in previous step, you can now use the following example which introduces the basic structure required to initialize and configure a player instance using the SDK.
It covers how to:
- Set up basic configuration via the struct
splayer_config_t - Report the device brand and model via
splayer_options_api-1.h - Use
splayerapi-5.hfor core API functions - Attempt pairing using
splayer_auth_api-1.h - Proper handling of the player lifecycle
While playback and pairing are not fully explained here, they are essential for a complete player implementation. For a complete player, including audio output, pairing, playback control and the automatic updater, see the reference app.
| main.c | |
|---|---|
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
The brand and model set with set_device_info are required: the player is not created without them. See the Requirements page for the format. vendor_device_name is a free name for the unit.
Copy paste the example above and put it inside your workspace directory (e.g. example-player/) and name it main.c.to run the example, execute the following commands in your terminal from your workspace directory:
cmake .
make
./example-player
Next Steps
- Reference app - Build and run our complete reference player to see how we use the C APIs, and experiment with it.
- Pairing – Learn about our authentication API and pairing your application with Soundtrack.
- SPlayer lifecycle – Learn how to properly manage the SPlayer lifecycle.
- Audio callbacks - Learn how audio callbacks work. You can use our provided ALSA or Darwin audio output implementations, or plug in your own.