Skip to main content
Version: 29.1.19

Audio API

Important Please Read​

To ensure the Skillz Audio API does not conflict with your current audio implementation please read carefully.

The Skillz SDK has an audio API that allows you to play custom background music for the Skillz UI, get/set your game's background music volume, and get/set your game's sound effects volume for consistent audio levels between Skillz and your game. Read more below for instructions on how to use this API.

Configuring Background Music for the SDK​

If you have music you’d like to play in the background for users when they are interacting with the SDK, you can use the Skillz Audio API to configure this.

The Skillz UI will play an internal background music file if you do not specify your own for playback**

Ensure Your Music File Is in the Correct Location​

First, make sure your music file is in the correct location of your project:

The file which contains the background music you’d like to play must be located in the `Assets/StreamingAssets` directory of your Unity project:

Unity project music file location

Call the API Method to Set the Music Source​

Tell the SDK which background music file to play in the Skillz UI. This file name must match exactly with the file’s name from the previous step.

SkillzCrossPlatform.setSkillzBackgroundMusic("music.mp3");
SkillzCrossPlatform.LaunchSkillz(SkillzGameController());

You can set the background music for Skillz anywhere after the app launches, but it is recommended to do so before launching the Skillz UI.

Syncing Your In-Game Volume with the Skillz SDK Audio​

Android Only: The functions in this section can only be used in-game after Skillz has launched.

Users can set volume settings from within the SDK via Accounts -> Audio Settings.

Audio settings

Each volume is represented as a range between 0 and 1, with 0 being muted and 1 being full volume.

If you would like your in-game volume to match with the values set by the user in the SDK (and vice-versa), use these instructions to synchronize the settings.

Synchronizing Your In-Game Volume with the Skillz SDK​

Getting the Background Music Volume​

For your game’s music, get the background music volume from the Skillz SDK when initially setting the music volume for your game to ensure that value matches the value set inside of the SDK.  In our example, we’re using a volume slider to control the in-game music volume, and to initialize its value we call the API like so:

SkillzCrossPlatform.getSkillzMusicVolume(float volume);

Getting the Sound Effects Volume​

For your game’s sound effects, get the sound effect volume from the Skillz SDK when initially setting the sound effects volume for your game to ensure that matches the value set inside of the SDK. In our example, we’re using a volume slider to control the in-game sound effects volume, and to initialize its value we call the API like so:

SkillzCrossPlatform.getSFXVolume();

Our end result when initializing the settings inside of a test app is similar to that pictured below. If a user adjusts their volume sliders in the Skillz menu, that change will reflect in these in-app sliders:

Unity volume sliders

Synchronizing the Skillz SDK volume with your In-Game volume​

If you utilize an in-game menu which allows the user to change their volume settings, use these methods to ensure the Skillz SDK will play at the same volume. 

Setting the Background Music Volume​

When a user changes your game’s music volume, set the background music volume in the SDK to keep the value in sync between your game and Skillz. Ensure the value is between 0 and 1.

Please make sure to sanitize your values; the API can take in values outside of the 0-1 range but this will cause problems.

Using the example from above, our code would look like this:

SkillzCrossPlatform.setSkillzMusicVolume(float volume);

Setting the Sound Effects Volume​

When a user changes your game’s sound effects volume, set the sound effects volume in the SDK to keep the value in sync between your game and Skillz. Ensure the value is between 0 and 1.

Please make sure to sanitize your values; the API can take in values outside of the 0-1 range but this will cause problems.

Using the example from above, our code would look like this:

void SkillzCrossPlatform.setSFXVolume(volume);