Audio Controls for iOS

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.

Step 1: Ensure your music file is in the correct location

The file which contains the background music you’d like to play must be located in directly in the root of your Xcode project.  An example is pictured below

Screen_Shot_2019-03-07_at_11.54.55_AM.png

Step 2: Call the API method to set the music source

Use setSkillzBackgroundMusicFile to set the background music that will play in the Skillz SDK. This file name must match exactly with the file’s name in Step 1.

[[Skillz skillzInstance] setBackgroundMusicFile:@"music.mp3"];
[[Skillz skillzInstance] launchSkillz];

This can be called anywhere after the app launches, but it is recommended to call this before launching the Skillz SDK.

Syncing Your In-Game Volume with the Skillz SDK Audio

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

unnamed.png

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.

Step 1: Synchronizing your in-game volume with the Skillz SDK

For your game’s music, use getBackgroundMusicVolume 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:

[self.musicVolumeSlider setValue:[[Skillz skillzInstance] getBackgroundMusicVolume]];

For your game’s sound effects, use getSFXVolume 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:

[[self.sfxVolumeSlider setValue:[[Skillz skillzInstance] 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:

Test_App_Audio.png

Step 2: 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. 

When a user changes your game’s music volume, use setBackgroundMusicVolume to synchronize that value with the SDK.  Ensure the value is between 0 and 1. (Note: 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 Step 1 above, our code would look like this:

[[Skillz skillzInstance] setBackgroundMusicVolume:musicSlider.value];

When a user changes your game’s sound effects volume, use setSFXVolume to synchronize with the SDK.  Ensure the value is between 0 and 1. (Note: 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 Step 1 above, our code would look like this:  

[[Skillz skillzInstance] setSFXVolume:sfxSlider.value];