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)
- Retrieve errors.
At its core, the SDK delivers raw PCM audio samples, but example audio integrations 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/
├── bin/ # Precompiled example executables (from src/)
├── 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_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
├── src/ # Example source code and mock player implementations
├── CMakeLists.txt # CMake configuration for building examples
└── 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
- Use
splayerapi-5.h
for 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 more advanced examples — including real-time audio and control loops, refer to the examples in the provided SDK -src/
directory.
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 |
|
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
- Examples in
src/
- Review more in-depth SDK player examples, which demonstrate how to use our C APIs. - 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.