API Reference eSDK 3.208.26

Main



_10
#include "spotify_embedded.h"

Macros and Constants


Return to header index
SP_API_VERSION82
SP_RECOMMENDED_MEMORY_BLOCK_SIZE1024 * 1024
SP_MAX_BRAND_NAME_LENGTH32
SP_MAX_MODEL_NAME_LENGTH30
SP_MAX_PLATFORM_NAME_LENGTH64
SP_MAX_CLIENT_ID_LENGTH32
SP_MAX_OS_VERSION_LENGTH64
SP_MAX_DISPLAY_NAME_LENGTH64
SP_MAX_AD_USER_AGENT_LENGTH256
SP_MAX_UNIQUE_ID_LENGTH64
SP_MAX_USERNAME_LENGTH64
SP_MAX_DEVICE_ALIASES8
SP_MAX_AD_METADATA_PAIRS4
SP_NO_ALIAS_SELECTED-1
SP_MAX_PLAYER_MODES8
SP_MAX_MODE_KEY_LENGTH32
SP_MAX_MODE_VALUE_LENGTH32
SP_MAX_METADATA_NAME_LENGTH255
SP_MAX_METADATA_URI_LENGTH127
SP_MAX_TRACK_UID_LENGTH64
SP_MAX_METADATA_IMAGE_URL_LENGTH255
SP_PLAYER_COOKIE_LENGTH32
SP_MAX_PLAYBACK_ID_LENGTH32
SP_MAX_PUBLIC_KEY_LENGTH149
SP_MAX_DEVICE_ID_LENGTH64
SP_MAX_DEVICE_TYPE_LENGTH15
SP_MAX_VERSION_LENGTH30
SP_MAX_GROUP_STATUS_LENGTH15
SP_MAX_TOKEN_TYPE_LENGTH30
SP_MAX_SCOPE_LENGTH64
SP_MAX_CLIENT_KEY_LENGTH511
SP_MAX_ZEROCONF_BLOB_LENGTH2047
SP_MAX_LOGIN_ID_LENGTH64
SP_MAX_AVAILABILITY_LENGTH15
SP_MAX_PARTNER_NAME_LENGTH48
SP_MAX_FILENAME_LENGTH63
SP_MAX_RESPONSE_SOURCE_LENGTH20
SP_ZEROCONF_DISABLED0
SP_ZEROCONF_SERVE1
SP_ZEROCONF_SERVE_HTTP_ONLY2
SP_ZEROCONF_SERVE_MDNS_ONLY3
SP_SCOPE_STREAMING"streaming"
SP_DEVICE_ALIAS_ATTRIBUTE_GROUP1
SP_GLOBAL_ATTRIBUTE_VOICE2
SP_MAX_SUPPORTED_FORMATS8
SP_PLAYBACK_RESTRICTION_ALREADY_PAUSED1
SP_PLAYBACK_RESTRICTION_NOT_PAUSED2
SP_PLAYBACK_RESTRICTION_LICENSE_DISALLOW4
SP_PLAYBACK_RESTRICTION_AD_DISALLOW8
SP_PLAYBACK_RESTRICTION_NO_PREV_TRACK16
SP_PLAYBACK_RESTRICTION_NO_NEXT_TRACK32
SP_PLAYBACK_RESTRICTION_UNKNOWN64
SP_PLAYBACK_RESTRICTION_ENDLESS_CONTEXT128
SP_MAX_PLAYER_MODES_RESTRICTIONSMaximum number of Player Mode Restrictions eSDK can provide through SpPlaybackRestrictions in Metadata.
SP_MAX_PLAYER_MODE_VALUE_DISALLOW_REASONS16
SP_MAX_METADATA_KEY_LENGTH32
SP_MAX_METADATA_VALUE_LENGTH64

Data Structures


Return to header index
SpPlayerModeDisallowReasonsThis struct stores a Mode value and the restriction disallow reasons associated with it.
SpPlayerModeRestrictionsthis struct stores a Mode key and the list of restricted values.
SpPlaybackRestrictionsPlayback restrictions.
SpFormatMapping of which media formats are supported in which DRM.
SpMetadataTrack metadata.
SpAdMetadataKey value pair for Ad-related metadata.
SpZeroConfDeviceAliasZeroConf DeviceAlias.
SpZeroConfVarsZeroConf variables.
SpSampleFormatSample format of the audio data.
SpPlaybackCallbacksCallbacks to be registered with SpRegisterPlaybackCallbacks()
SpDebugCallbacksCallbacks to be registered with SpRegisterDebugCallbacks()
SpConnectionCallbacksCallbacks to be registered with SpRegisterConnectionCallbacks()
SpDeviceAliasDevice alias definition.
SpConfigConfiguration.
SpDeviceAliasCallbacksCallbacks to be registered with SpRegisterDeviceAliasCallbacks()

Typedefs


Return to header index
SpCallbackErrorCallback for reporting errors to the application.
SpCallbackPlaybackNotifyCallback for notifying the application about playback-related events.
SpCallbackPlaybackSeekCallback to notify the application of a change in the playback position.
SpCallbackPlaybackApplyVolumeCallback to notify the application of a volume change using Spotify Connect.
SpCallbackConnectionNotifyCallback for notifying the application about events related to the connection to Spotify.
SpCallbackConnectionNewCredentialsCallback for passing a login blob to the application.
SpCallbackConnectionMessageCallback for sending a message to the user.
SpCallbackDebugMessageCallback for sending debug messages/trace logs.
SpCallbackSelectedDeviceAliasChangedCallback for receiving the selected device alias from the backend.
SpCallbackDeviceAliasesUpdateDoneCallback for knowing when the device alias list has been updated after call to SpSetDeviceAliases()

Enumerations


Return to header index
SpErrorError codes.
SpAPIReturnCodeEnum describes return codes that public API functions can report to eSDK.
SpPlaybackBitrateValid bitrate values. This enum is used for selecting the audio quality of the files to play.
SpPlaybackNotificationPlayback-related notification events.
SpConnectionNotificationNotifications related to the connection to Spotify.
SpDeviceTypeDevice type reported to client applications.
SpMetadataTrackMetadata track selector.
SpConnectivityType of network connection.
SpContentContent type.
SpMediaTypeMedia Type.
SpAudioQualityAudio quality.
SpDrmFormatDRM formats.
SpReDeliveryModeRedelivery mode types.

Functions


Return to header index
SpInitInitialize the library.
SpFreeShut down the library.
SpGetLibraryVersionRetrieve a version string for the library.
SpConnectionSetConnectivitySet the type of network connection of the device.
SpConnectionGetConnectivityGet the connectivity that was set with SpConnectionSetConnectivity()
SpConnectionLoginBlobLog in a user to Spotify using a credentials blob.
SpConnectionLoginOauthTokenLog in a user to Spotify using a Spotify OAuth token.
SpConnectionLogoutLog the user out of Spotify.
SpConnectionIsLoggedInIs the user logged in to Spotify.
SpConnectionGetAckIdGet the last Ack ID.
SpGetCanonicalUsernameGet the canonical username of the logged in user.
SpSetDisplayNameSet the display name for the device or application.
SpSetVolumeStepsSet the volume steps the device is capable of.
SpSetDeviceIsGroupControl if the device represents a group.
SpEnableConnectEnable Connect functionality for this device.
SpDisableConnectDisable Connect functionality for this device.
SpGetSelectedDeviceAliasReturn the currently selected device alias.
SpPumpEventsAllow the library to perform asynchronous tasks and process events.
SpRegisterConnectionCallbacksRegister callbacks related to the connection to Spotify.
SpRegisterDebugCallbacksRegister a callback that receives debug messages/trace logs.
SpRegisterPlaybackCallbacksRegister playback-related callbacks.
SpGetMetadataRetrieve metadata for a track in the current track list.
SpGetMetadataImageURLReturn the HTTP URL to an image file from a spotify:image: URI.
SpGetPlayerCookieObtain player cookie for current playback.
SpPlaybackPlayStart or resume playback.
SpPlaybackPausePause playback.
SpPlaybackSkipToNextSkip playback to the next track in the track list.
SpPlaybackSkipToPrevSkip playback to the previous track in the track list.
SpPlaybackSeekSeek to a position within the current track.
SpPlaybackSeekRelativeSeek a relative amount of time within the current track.
SpPlaybackGetPositionGet the current playback position within the track.
SpPlaybackUpdateVolumeRequest a change to the playback volume.
SpPlaybackGetVolumeGet the playback volume level.
SpPlaybackIsPlayingIs the playback status playing or paused.
SpPlaybackIsAdPlayingIs the current track an Ad or not.
SpPlaybackIsShuffledIs "shuffle" mode enabled.
SpPlaybackIsRepeatedIs "repeat" mode enabled.
SpPlaybackGetRepeatModeWhich "repeat" mode is on.
SpPlaybackIsActiveDeviceIs the device the active playback device.
SpPlaybackEnableShuffleEnable or disable "shuffle" mode.
SpPlaybackEnableRepeatEnable or disable "repeat" mode.
SpPlaybackCycleRepeatModeCycle through the available repeat modes.
SpPlaybackSetBitrateChange the bitrate at which compressed audio data is delivered.
SpPlaybackSetDeviceInactiveSet the device inactive.
SpPlaybackIsDeviceControllableIs the device controllable.
SpPlaybackSetDeviceControllableAllow or disallow the device to be controllable.
SpPlaybackIncreaseUnderrunCountIncrease the underrun counter of the current track.
SpPlaybackSetBandwidthLimitSet a limit on the download speed.
SpPlaybackSetRedeliveryModeActivates redelivery of audio data on play or resume playback.
SpPlaybackIsRedeliveryModeActivatedGets the status of redelivery mode.
SpZeroConfGetVarsGet variables for ZeroConf, mainly the "getInfo" request.
SpZeroConfAnnouncePauseTemporarily pause ZeroConf mDNS announcements.
SpZeroConfAnnounceResumeResume ZeroConf mDNS announcement after calling SpZeroConfAnnouncePause()
SpConnectionLoginZeroConfLog in a user to Spotify using a ZeroConf credentials blob.
SpGetBrandName
SpGetModelName
SpRegisterDeviceAliasCallbacksRegister callbacks related to device aliases.
SpSetDeviceAliasesUpdate the device alias definitions.
SpSetAdUserAgentSet the ad user agent.
SpRestrictDrmMediaFormatsRestrict DRM/Media formats.

SP_API_VERSION


Return to header index

_10
#define SP_API_VERSION 82

The version of the API defined in this header file.

See also

SP_RECOMMENDED_MEMORY_BLOCK_SIZE


Return to header index

_10
#define SP_RECOMMENDED_MEMORY_BLOCK_SIZE 1024 * 1024

Minimum recommended size of the buffer SpConfig::memory_block.

SP_MAX_BRAND_NAME_LENGTH


Return to header index

_10
#define SP_MAX_BRAND_NAME_LENGTH 32

Maximum length of the brand name string (not counting terminating NULL)

See also

SP_MAX_MODEL_NAME_LENGTH


Return to header index

_10
#define SP_MAX_MODEL_NAME_LENGTH 30

Maximum length of the model name string (not counting terminating NULL)

See also

SP_MAX_PLATFORM_NAME_LENGTH


Return to header index

_10
#define SP_MAX_PLATFORM_NAME_LENGTH 64

Maximum length of the platform_name string (not counting terminating NULL)

See also

SP_MAX_CLIENT_ID_LENGTH


Return to header index

_10
#define SP_MAX_CLIENT_ID_LENGTH 32

Maximum length of the client id string (not counting terminating NULL)

See also

SP_MAX_OS_VERSION_LENGTH


Return to header index

_10
#define SP_MAX_OS_VERSION_LENGTH 64

Maximum length of the os version string (not counting terminating NULL)

See also

SP_MAX_DISPLAY_NAME_LENGTH


Return to header index

_10
#define SP_MAX_DISPLAY_NAME_LENGTH 64

Maximum length of the device display name (not counting terminating NULL)

See also

SP_MAX_AD_USER_AGENT_LENGTH


Return to header index

_10
#define SP_MAX_AD_USER_AGENT_LENGTH 256

Maximum length of the ad UserAgent (not counting terminating NULL)

See also

SP_MAX_UNIQUE_ID_LENGTH


Return to header index

_10
#define SP_MAX_UNIQUE_ID_LENGTH 64

Maximum length of the device's unique ID (not counting terminating NULL)

See also

SP_MAX_USERNAME_LENGTH


Return to header index

_10
#define SP_MAX_USERNAME_LENGTH 64

Maximum length of usernames (not counting terminating NULL)

See also

SP_MAX_DEVICE_ALIASES


Return to header index

_10
#define SP_MAX_DEVICE_ALIASES 8

Maximum number of device aliases that can be configured.

See also

SP_MAX_AD_METADATA_PAIRS


Return to header index

_10
#define SP_MAX_AD_METADATA_PAIRS 4

Maximum number of key/value pairs containing ad metadata.

SP_NO_ALIAS_SELECTED


Return to header index

_10
#define SP_NO_ALIAS_SELECTED -1

A value to use for alias_index when aliases are not used.

See also

SP_MAX_PLAYER_MODES


Return to header index

_10
#define SP_MAX_PLAYER_MODES 8

Maximum number of Player Option Modes eSDK can provide when calling SpPlaybackGetPlayerModes()

Note: reserved for future use.

SP_MAX_MODE_KEY_LENGTH


Return to header index

_10
#define SP_MAX_MODE_KEY_LENGTH 32

Maximum length of the key field in struct SpPlayerModePair.

Note: reserved for future use.

SP_MAX_MODE_VALUE_LENGTH


Return to header index

_10
#define SP_MAX_MODE_VALUE_LENGTH 32

Maximum length of the value field in struct SpPlayerModePair.

Note: reserved for future use.

SP_MAX_METADATA_NAME_LENGTH


Return to header index

_10
#define SP_MAX_METADATA_NAME_LENGTH 255

Maximum length of display names in track metadata (not counting terminating NULL)

See also Notes:

SP_MAX_METADATA_URI_LENGTH


Return to header index

_10
#define SP_MAX_METADATA_URI_LENGTH 127

Maximum length of URIs in track metadata (not counting terminating NULL)

See also

SP_MAX_TRACK_UID_LENGTH


Return to header index

_10
#define SP_MAX_TRACK_UID_LENGTH 64

Maximum length of Track UID in track metadata (not counting terminating NULL)

See also

SP_MAX_METADATA_IMAGE_URL_LENGTH


Return to header index

_10
#define SP_MAX_METADATA_IMAGE_URL_LENGTH 255

Maximum length of URLs (not counting terminating NULL)

See also

SP_PLAYER_COOKIE_LENGTH


Return to header index

_10
#define SP_PLAYER_COOKIE_LENGTH 32

Length of player cookie (not counting terminating NULL)

See also

SP_MAX_PLAYBACK_ID_LENGTH


Return to header index

_10
#define SP_MAX_PLAYBACK_ID_LENGTH 32

Maximum length of Playback-Id (not counting terminating NULL)

See also

SP_MAX_PUBLIC_KEY_LENGTH


Return to header index

_10
#define SP_MAX_PUBLIC_KEY_LENGTH 149

Maximum length of the public key used in ZeroConf logins (not counting terminating NULL)

See also

SP_MAX_DEVICE_ID_LENGTH


Return to header index

_10
#define SP_MAX_DEVICE_ID_LENGTH 64

Maximum length of the device ID used for ZeroConf logins (not counting terminating NULL)

See also

SP_MAX_DEVICE_TYPE_LENGTH


Return to header index

_10
#define SP_MAX_DEVICE_TYPE_LENGTH 15

Maximum length of the device type string (not counting terminating NULL)

See also

SP_MAX_VERSION_LENGTH


Return to header index

_10
#define SP_MAX_VERSION_LENGTH 30

Maximum length of the library version string (not counting terminating NULL)

See also

SP_MAX_GROUP_STATUS_LENGTH


Return to header index

_10
#define SP_MAX_GROUP_STATUS_LENGTH 15

Maximum length of the group status string (not counting terminating NULL)

See also

SP_MAX_TOKEN_TYPE_LENGTH


Return to header index

_10
#define SP_MAX_TOKEN_TYPE_LENGTH 30

Maximum length of the token type used for OAuth logins (not counting terminating NULL)

See also

SP_MAX_SCOPE_LENGTH


Return to header index

_10
#define SP_MAX_SCOPE_LENGTH 64

Maximum length of the scope used for OAuth login (not counting terminating NULL)

See also

SP_MAX_CLIENT_KEY_LENGTH


Return to header index

_10
#define SP_MAX_CLIENT_KEY_LENGTH 511

Maximum length of the client key (not counting terminating NULL)

See also

SP_MAX_ZEROCONF_BLOB_LENGTH


Return to header index

_10
#define SP_MAX_ZEROCONF_BLOB_LENGTH 2047

Maximum length of the ZeroConf blob (not counting terminating NULL)

See also

SP_MAX_LOGIN_ID_LENGTH


Return to header index

_10
#define SP_MAX_LOGIN_ID_LENGTH 64

Maximum length of the login ID used for ZeroConf logins (not counting terminating NULL)

See also

SP_MAX_AVAILABILITY_LENGTH


Return to header index

_10
#define SP_MAX_AVAILABILITY_LENGTH 15

Maximum length of the availability string (not counting terminating NULL)

See also

SP_MAX_PARTNER_NAME_LENGTH


Return to header index

_10
#define SP_MAX_PARTNER_NAME_LENGTH 48

Maximum length of the Partner Name (TSP_PARTNER_NAME) (not counting terminating NULL) The longest partner name when this was written was "imagination_technologies_mips" at 29 characters.

SP_MAX_FILENAME_LENGTH


Return to header index

_10
#define SP_MAX_FILENAME_LENGTH 63

Maximum length of filename fields (not counting terminating NULL)

SP_MAX_RESPONSE_SOURCE_LENGTH


Return to header index

_10
#define SP_MAX_RESPONSE_SOURCE_LENGTH 20

Maximum length of the response source string (not counting terminating NULL)

SP_ZEROCONF_DISABLED


Return to header index

_10
#define SP_ZEROCONF_DISABLED 0

Value for SpConfig::zeroconf_serve when disabling built-in ZeroConf stack. Complete ZeroConf stack has to run externally.

See also

SP_ZEROCONF_SERVE


Return to header index

_10
#define SP_ZEROCONF_SERVE 1

Value for SpConfig::zeroconf_serve when activating complete built-in ZeroConf stack (both mDNS and http server).

See also

SP_ZEROCONF_SERVE_HTTP_ONLY


Return to header index

_10
#define SP_ZEROCONF_SERVE_HTTP_ONLY 2

Value for SpConfig::zeroconf_serve when activating built-in ZeroConf http server only while running the ZeroConf mDNS server externally.

See also

SP_ZEROCONF_SERVE_MDNS_ONLY


Return to header index

_10
#define SP_ZEROCONF_SERVE_MDNS_ONLY 3

Value for SpConfig::zeroconf_serve when activating built-in ZeroConf mDNS server only while running the ZeroConf http server externally.

See also

SP_SCOPE_STREAMING


Return to header index

_10
#define SP_SCOPE_STREAMING "streaming"

Value for SpConfig::scope when implementing a basic streaming device.

SP_DEVICE_ALIAS_ATTRIBUTE_GROUP


Return to header index

_10
#define SP_DEVICE_ALIAS_ATTRIBUTE_GROUP 1

Set this bit in the device alias attributes integer (SpDeviceAlias::attributes) to mark a device alias as representing a group.

Notes:

SP_GLOBAL_ATTRIBUTE_VOICE


Return to header index

_10
#define SP_GLOBAL_ATTRIBUTE_VOICE 2

Set this bit in the global attributes integer (SpConfig::global_attributes) to mark that this device supports voice.

SP_MAX_SUPPORTED_FORMATS


Return to header index

_10
#define SP_MAX_SUPPORTED_FORMATS 8

See also

SP_PLAYBACK_RESTRICTION_ALREADY_PAUSED


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_ALREADY_PAUSED 1

The track is already paused.

SP_PLAYBACK_RESTRICTION_NOT_PAUSED


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_NOT_PAUSED 2

The track is already playing.

SP_PLAYBACK_RESTRICTION_LICENSE_DISALLOW


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_LICENSE_DISALLOW 4

Licensing rules disallow this action.

SP_PLAYBACK_RESTRICTION_AD_DISALLOW


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_AD_DISALLOW 8

Action can't be performed while an ad is playing.

SP_PLAYBACK_RESTRICTION_NO_PREV_TRACK


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_NO_PREV_TRACK 16

There is no track before the current one in the currently playing context.

SP_PLAYBACK_RESTRICTION_NO_NEXT_TRACK


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_NO_NEXT_TRACK 32

There is no track after the current one in the currently playing context.

SP_PLAYBACK_RESTRICTION_UNKNOWN


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_UNKNOWN 64

The action is restricted, but no reason is provided.

This means that eSDK has not retrieved the restrictions from the backend yet and therefore the action is not allowed right now. As soon as eSDK retrieves the information, the notification kSpPlaybackNotifyMetadataChanged will be sent, and the application can check the field again.

SP_PLAYBACK_RESTRICTION_ENDLESS_CONTEXT


Return to header index

_10
#define SP_PLAYBACK_RESTRICTION_ENDLESS_CONTEXT 128

The action is restricted for context level reasons.

SP_MAX_PLAYER_MODES_RESTRICTIONS


Return to header index

_10
#define SP_MAX_PLAYER_MODES_RESTRICTIONS

Maximum number of Player Mode Restrictions eSDK can provide through SpPlaybackRestrictions in Metadata.

Note: reserved for future use.

SP_MAX_PLAYER_MODE_VALUE_DISALLOW_REASONS


Return to header index

_10
#define SP_MAX_PLAYER_MODE_VALUE_DISALLOW_REASONS 16

Maximum number of restriction disallow reasons per value of a Player Mode.

SP_MAX_METADATA_KEY_LENGTH


Return to header index

_10
#define SP_MAX_METADATA_KEY_LENGTH 32

Maximum number of characters in the key of a SpAdMetadata struct, not counting the terminating NULL.

See also

SP_MAX_METADATA_VALUE_LENGTH


Return to header index

_10
#define SP_MAX_METADATA_VALUE_LENGTH 64

Maximum number of characters in the value of a SpAdMetadata struct, not counting the terminating NULL.

See also

SpPlayerModeDisallowReasons


Return to header index

_10
struct SpPlayerModeDisallowReasons {
_10
char value;
_10
uint32_t disallow_reasons;
_10
};

This struct stores a Mode value and the restriction disallow reasons associated with it.

char valueA null-terminated string to represent the value of the restricted Player Mode.
uint32_t disallow_reasonsBitfield of reasons for disallowing setting the mode value.

SpPlayerModeRestrictions


Return to header index

_10
struct SpPlayerModeRestrictions {
_10
char key;
_10
struct SpPlayerModeDisallowReasons reasons;
_10
};

this struct stores a Mode key and the list of restricted values.

char keyA null-terminated string to represent the key of the Player Mode that is restricted.
struct SpPlayerModeDisallowReasons reasonsthe list of restricted values and the disallow reasons.

SpPlaybackRestrictions


Return to header index

_12
struct SpPlaybackRestrictions {
_12
uint32_t disallow_pausing_reasons;
_12
uint32_t disallow_resuming_reasons;
_12
uint32_t disallow_seeking_reasons;
_12
uint32_t disallow_peeking_prev_reasons;
_12
uint32_t disallow_peeking_next_reasons;
_12
uint32_t disallow_skipping_prev_reasons;
_12
uint32_t disallow_skipping_next_reasons;
_12
uint32_t disallow_toggling_repeat_context_reasons;
_12
uint32_t disallow_toggling_repeat_track_reasons;
_12
uint32_t disallow_toggling_shuffle_reasons;
_12
};

Playback restrictions.

uint32_t disallow_pausing_reasonsBitfield of reasons the pause action is not allowed.
uint32_t disallow_resuming_reasonsBitfield of reasons the resume action is not allowed.
uint32_t disallow_seeking_reasonsBitfield of reasons seeking is not allowed.
uint32_t disallow_peeking_prev_reasonsBitfield of reasons peeking on the previous track is not allowed.
uint32_t disallow_peeking_next_reasonsBitfield of reasons peeking on the next track is not allowed.
uint32_t disallow_skipping_prev_reasonsBitfield of reasons skipping to the previous track is not allowed.
uint32_t disallow_skipping_next_reasonsBitfield of reasons skipping to the next track is not allowed.
uint32_t disallow_toggling_repeat_context_reasonsBitfield of reasons setting repeat context is not allowed.
uint32_t disallow_toggling_repeat_track_reasonsBitfield of reasons setting repeat track is not allowed.
uint32_t disallow_toggling_shuffle_reasonsBitfield of reasons toggling shuffle is not allowed.

SpFormat


Return to header index

_10
struct SpFormat {
_10
enum SpDrmFormat drm;
_10
uint64_t media;
_10
};

Mapping of which media formats are supported in which DRM.

See also
enum SpDrmFormat drmDRM format which the integration supports.
uint64_t mediaSupported media formats for a DRM.

SpMetadata


Return to header index

_22
struct SpMetadata {
_22
char playback_source;
_22
char playback_source_uri;
_22
char track;
_22
char track_uri;
_22
char artist;
_22
char artist_uri;
_22
char album;
_22
char album_uri;
_22
char album_cover_uri;
_22
char original_track_uri;
_22
uint32_t duration_ms;
_22
int32_t index;
_22
char track_uid;
_22
uint32_t original_index;
_22
uint32_t bitrate;
_22
struct SpPlaybackRestrictions playback_restrictions;
_22
char playback_id;
_22
enum SpContent content_type;
_22
enum SpMediaType media_type;
_22
enum SpAudioQuality audio_quality;
_22
};

Track metadata.

See also
char playback_sourceDisplay name of the playback source. E.g., the name of the playlist from which playback was initiated (UTF-8-encoded)
char playback_source_uriSpotify URI of the playback source (in the form "spotify:xxxxxx:xxxxxxx...")
char trackDisplay name of the track (UTF-8-encoded)
char track_uriSpotify URI of the track (in the form "spotify:track:xxxxxxx...")
char artistDisplay name of the artist of the track (UTF-8-encoded)
char artist_uriSpotify URI of the artist of the track (in the form "spotify:artist:xxxxxxx...")
char albumDisplay name of the track's album (UTF-8-encoded)
char album_uriSpotify URI of the track's album (in the form "spotify:album:xxxxxxx...")
char album_cover_uriSpotify URI of the album's cover art image (in the form "spotify:image:xxxxxxx...")
char original_track_uriSpotify URI of the original track before relinking (in the form "spotify:track:xxxxxxx...")
uint32_t duration_msPlayback duration of the track in milliseconds.
int32_t indexIndex of the track in the currently playing context.
char track_uidTrack UID of the track in the currently playing context.
uint32_t original_indexIndex of the track in the original (unchanged) playing context.
uint32_t bitrateThe bitrate of the track in kbps. 0 means "unplayable".
struct SpPlaybackRestrictions playback_restrictionsRestrictions that apply to playback and transitions related to this track.
char playback_idPlayback-id of this playback of this specific track.
enum SpContent content_typeContent type of this track.
enum SpMediaType media_typeMedia type of this track.
enum SpAudioQuality audio_qualityAudio quality of this track.

SpAdMetadata


Return to header index

_10
struct SpAdMetadata {
_10
char key;
_10
char value;
_10
};

Key value pair for Ad-related metadata.

char keyKey.
char valueValue.

SpZeroConfDeviceAlias


Return to header index

_10
struct SpZeroConfDeviceAlias {
_10
uint32_t id;
_10
int is_group;
_10
char display_name;
_10
};

ZeroConf DeviceAlias.

This structure contains information about a single device alias, as returned by SpZeroConfGetVars().

See also
uint32_t idString to be sent in the "id" field of the alias in the "getInfo" response.
int is_groupBoolean (0 = "false", 1 = "true") to be sent in the "isGroup" field of the alias in the "getInfo" response.
char display_nameString to be sent in the "name" field of the alias in the "getInfo" response.

SpZeroConfVars


Return to header index

_20
struct SpZeroConfVars {
_20
char public_key;
_20
char response_source;
_20
char device_id;
_20
char remote_name;
_20
char device_type;
_20
char library_version;
_20
int resolver_version;
_20
char group_status;
_20
int webserver_current_port;
_20
char token_type;
_20
char client_id;
_20
char scope;
_20
char availability;
_20
uint32_t product_id;
_20
struct SpZeroConfDeviceAlias aliases;
_20
uint32_t alias_count;
_20
struct SpFormat supported_drm_media_formats;
_20
uint64_t supported_capabilities;
_20
};

ZeroConf variables.

This structure contains the fields that the application needs for ZeroConf, mainly what to send in the response to the "getInfo" request. See the ZeroConf manual for more information.

See also
char public_keyString to be sent in the "publicKey" field of the "getInfo" response[*].
char response_sourceString to be sent in the "responseSource" field of the "getInfo" response[*].
char device_idString to be sent in the "deviceID" field of the "getInfo" response[*].
char remote_nameString to be sent in the "remoteName" field of the "getInfo" response[*].
char device_typeString to be sent in the "deviceType" field of the "getInfo" response[*].
char library_versionString to be sent in the "libraryVersion" field of the "getInfo" response[*].
int resolver_versionInteger to be sent as string in the "resolverVersion" field of the "getInfo" response[*].
char group_statusString to be sent in the "groupStatus" field of the "getInfo" response[*].
int webserver_current_portCurrent internal ZeroConf webserver port number. To be used when running an external mDNS server together with an internal webserver.
char token_typeString to be sent in the "tokenType" field of the "getInfo" response[*].
char client_idString to be sent in the "clientID" field of the "getInfo" response[*].
char scopeString to be sent in the "scope" field of the "getInfo" response[*].
char availabilityString to be sent in the "availability" field of the "getInfo" response[*].
uint32_t product_idInteger to be sent in the "productID" field of the "getInfo" response[*].
struct SpZeroConfDeviceAlias aliasesArray of SpZeroConfDeviceAlias to be sent in the "aliases" field of the "getInfo" response[*].
uint32_t alias_countNumber of valid items in aliases array.
struct SpFormat supported_drm_media_formatsArray of SpFormat to be sent in the "supported_drm_media_formats" field of the "getInfo" response[*].
uint64_t supported_capabilitiesInteger representing a bitmask to be sent in the "supported_capabilities" field of the "getInfo" response[*].

SpSampleFormat


Return to header index

_10
struct SpSampleFormat {
_10
int channels;
_10
int sample_rate;
_10
int bits_per_sample;
_10
};

Sample format of the audio data.

int channelsNumber of channels (1 = mono, 2 = stereo)
int sample_rateSample rate in Hz (such as 22050, 44100 or 48000)
int bits_per_sampleBits per sample (16 or 24)

SpPlaybackCallbacks


Return to header index

_10
struct SpPlaybackCallbacks {
_10
SpCallbackPlaybackNotify on_notify;
_10
SpCallbackPlaybackSeek on_seek;
_10
SpCallbackPlaybackApplyVolume on_apply_volume;
_10
};

Callbacks to be registered with SpRegisterPlaybackCallbacks()

Any of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackPlaybackNotify on_notifyNotification callback.
SpCallbackPlaybackSeek on_seekSeek position callback.
SpCallbackPlaybackApplyVolume on_apply_volumeApply volume callback.

SpDebugCallbacks


Return to header index

_10
struct SpDebugCallbacks {
_10
SpCallbackDebugMessage on_message;
_10
};

Callbacks to be registered with SpRegisterDebugCallbacks()

Any of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackDebugMessage on_messageDebug message callback.

SpConnectionCallbacks


Return to header index

_10
struct SpConnectionCallbacks {
_10
SpCallbackConnectionNotify on_notify;
_10
SpCallbackConnectionNewCredentials on_new_credentials;
_10
SpCallbackConnectionMessage on_message;
_10
};

Callbacks to be registered with SpRegisterConnectionCallbacks()

Any of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackConnectionNotify on_notifyNotification callback.
SpCallbackConnectionNewCredentials on_new_credentialsCredentials blob callback.
SpCallbackConnectionMessage on_messageConnection message callback.

SpDeviceAlias


Return to header index

_10
struct SpDeviceAlias {
_10
const char *display_name;
_10
uint32_t attributes;
_10
};

Device alias definition.

This struct is used to define (optional) device aliases. It's a part of the SpConfig struct which will be passed to SpInit() to initialize the eSDK.

const char * display_nameA UTF-8 encoded display name for an alias of the application/device.
uint32_t attributesAttributes for this device alias.

SpConfig


Return to header index

_28
struct SpConfig {
_28
int api_version;
_28
void *memory_block;
_28
uint32_t memory_block_size;
_28
const char *unique_id;
_28
const char *display_name;
_28
uint32_t global_attributes;
_28
struct SpDeviceAlias device_aliases;
_28
const char *brand_name;
_28
const char *brand_display_name;
_28
const char *model_name;
_28
const char *model_display_name;
_28
const char *platform_name;
_28
const char *client_id;
_28
uint32_t product_id;
_28
const char *scope;
_28
const char *os_version;
_28
enum SpDeviceType device_type;
_28
enum SpPlaybackBitrate max_bitrate;
_28
SpCallbackError error_callback;
_28
void *error_callback_context;
_28
int zeroconf_serve;
_28
const char *host_name;
_28
int zeroconf_port;
_28
int zeroconf_port_range;
_28
struct SpFormat supported_drm_media_formats;
_28
struct SpAdMetadata ad_metadata;
_28
};

Configuration.

See also
int api_versionThe version of the API contained in this header file. Must be set to SP_API_VERSION.
void * memory_blockPointer to a memory block to be used by the library.
uint32_t memory_block_sizeSize of the memory_block buffer in bytes.
const char * unique_idA NULL-terminated character string that uniquely identifies the device (such as a MAC address)
const char * display_nameA UTF-8-encoded display name for the application/device.
uint32_t global_attributesThe global attributes is a bitfield where each attribute is OR:ed together and stored in this integer.
struct SpDeviceAlias device_aliasesDevice alias definitions. These are optional, if you don't want to define aliases this array must be zeroed.
const char * brand_nameA NULL-terminated string containing the brand name of the hardware device (for hardware integrations)
const char * brand_display_nameA UTF-8-encoded brand name of the hardware device (for hardware integrations). Should be very similar to brand_name.
const char * model_nameA NULL-terminated string containing the model name of the hardware device (for hardware integrations)
const char * model_display_nameA UTF-8-encoded model name of the hardware device (for hardware integrations)
const char * platform_nameA NULL-terminated string containing the platform identifier.
const char * client_idA NULL-terminated string containing the client id of the application.
uint32_t product_idAn integer enumerating the product for this partner.
const char * scopeA NULL-terminated string containing the OAuth scope requested when authenticating with the Spotify backend.
const char * os_versionA NULL-terminated string containing the os version running on the hardware.
enum SpDeviceType device_typeThe device type that best describes this product.
enum SpPlaybackBitrate max_bitrateThe maximum bitrate to use for playback.
SpCallbackError error_callbackPointer to a callback function that will receive error notifications.
void * error_callback_contextApplication-defined pointer that will be passed unchanged as the context argument to the error_callback callback.
int zeroconf_serveNot applicable in this eSDK configuration.
const char * host_nameNot applicable in this eSDK configuration.
int zeroconf_portNot applicable in this eSDK configuration.
int zeroconf_port_rangeNot applicable in this eSDK configuration.
struct SpFormat supported_drm_media_formats
struct SpAdMetadata ad_metadataFor clients that need to register ad-relasted metadata.

SpDeviceAliasCallbacks


Return to header index

_10
struct SpDeviceAliasCallbacks {
_10
SpCallbackSelectedDeviceAliasChanged on_selected_device_alias_changed;
_10
SpCallbackDeviceAliasesUpdateDone on_device_aliases_update_done;
_10
};

Callbacks to be registered with SpRegisterDeviceAliasCallbacks()

Any of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackSelectedDeviceAliasChanged on_selected_device_alias_changedSelected device alias updated callback.
SpCallbackDeviceAliasesUpdateDone on_device_aliases_update_doneDevice alias list updated.

SpCallbackError


Return to header index

_10
typedef void(* SpCallbackError) (SpError error, void *context)

Callback for reporting errors to the application.

To register this callback, set the field SpConfig::error_callback when invoking the function SpInit().

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackPlaybackNotify


Return to header index

_10
typedef void(* SpCallbackPlaybackNotify) (enum SpPlaybackNotification event, void *context)

Callback for notifying the application about playback-related events.

To register this callback, use the function SpRegisterPlaybackCallbacks().

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackPlaybackSeek


Return to header index

_10
typedef void(* SpCallbackPlaybackSeek) (uint32_t position_ms, void *context)

Callback to notify the application of a change in the playback position.

To register this callback, use the function SpRegisterPlaybackCallbacks(). This callback is invoked when SpPlaybackSeek() is invoked or when the user seeks to a position within the track using Spotify Connect.

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackPlaybackApplyVolume


Return to header index

_10
typedef void(* SpCallbackPlaybackApplyVolume) (uint16_t volume, uint8_t remote, void *context)

Callback to notify the application of a volume change using Spotify Connect.

To register this callback, use the function SpRegisterPlaybackCallbacks(). This callback is invoked in two cases: When the user changes the playback volume using Spotify Connect. When the application invoked SpPlaybackUpdateVolume(). In both cases, the application is responsible for applying the new volume to its audio output. The application should never invoke SpPlaybackUpdateVolume() from this callback, as this might result in an endless loop.

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackConnectionNotify


Return to header index

_10
typedef void(* SpCallbackConnectionNotify) (enum SpConnectionNotification event, void *context)

Callback for notifying the application about events related to the connection to Spotify.

To register this callback, use the function SpRegisterConnectionCallbacks().

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackConnectionNewCredentials


Return to header index

_10
typedef void(* SpCallbackConnectionNewCredentials) (const char *credentials_blob, const char *username, void *context)

Callback for passing a login blob to the application.

To register this callback, use the function SpRegisterConnectionCallbacks(). The application may save the credentials_blob for subsequent logins using the function SpConnectionLoginBlob(). The application should also discard any credentials blobs for this user that it received previously, either through this callback or through ZeroConf (see the ZeroConf manual). Note: If credentials_blob is an empty string, the application MUST delete any existing saved credentials for the account, and must not attempt to login again with the empty credentials. This happens when a permanent logout is requested.

See also Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackConnectionMessage


Return to header index

_10
typedef void(* SpCallbackConnectionMessage) (const char *message, void *context)

Callback for sending a message to the user.

To register this callback, use the function SpRegisterConnectionCallbacks(). This callback is invoked when Spotify wants to display a message to the user. The message is meant to be displayed to the user as-is and should not be interpreted by the application (the format of the messages may change without notice). If the application does not have a graphical user interface, it can safely ignore this callback.

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackDebugMessage


Return to header index

_10
typedef void(* SpCallbackDebugMessage) (const char *debug_message, void *context)

Callback for sending debug messages/trace logs.

To register this callback, use the function SpRegisterDebugCallbacks(). In special builds of the library, this callback receives debug messages that the application may write to its logs. The application should not interpret the messages (the format of the messages may change without notice).

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackSelectedDeviceAliasChanged


Return to header index

_10
typedef void(* SpCallbackSelectedDeviceAliasChanged) (uint32_t alias_index, void *context)

Callback for receiving the selected device alias from the backend.

To register this callback, use the function SpRegisterDeviceAliasCallbacks(). This callback is invoked whenever the selected device alias is updated. This can happen when, for example, the user selects an alias from Spotify Connect device picker.

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpCallbackDeviceAliasesUpdateDone


Return to header index

_10
typedef void(* SpCallbackDeviceAliasesUpdateDone) (SpError error_code, void *context)

Callback for knowing when the device alias list has been updated after call to SpSetDeviceAliases()

To register this callback, use the function SpRegisterDeviceAliasCallbacks(). This callback is invoked when the operation started by SpSetDeviceAliases() has finished.

Notes:
  • The application should not block or call API functions that are not allowed in the callback.

SpError


Return to header index

_10
enum SpError {
_10
_10
};

Error codes.

These are the possible status codes returned by functions in the SDK. They should be used to determine if an action was successful, and if not, why the action failed.

See also

SpAPIReturnCode


Return to header index

_10
enum SpAPIReturnCode {
_10
_10
};

Enum describes return codes that public API functions can report to eSDK.

SpPlaybackBitrate


Return to header index

_10
enum SpPlaybackBitrate {
_10
_10
};

Valid bitrate values. This enum is used for selecting the audio quality of the files to play.

See also

SpPlaybackNotification


Return to header index

_10
enum SpPlaybackNotification {
_10
_10
};

Playback-related notification events.

See also

SpConnectionNotification


Return to header index

_10
enum SpConnectionNotification {
_10
_10
};

Notifications related to the connection to Spotify.

See also

SpDeviceType


Return to header index

_10
enum SpDeviceType {
_10
_10
};

Device type reported to client applications.

SpMetadataTrack


Return to header index

_10
enum SpMetadataTrack {
_10
_10
};

Metadata track selector.

See also

SpConnectivity


Return to header index

_10
enum SpConnectivity {
_10
_10
};

Type of network connection.

See also

SpContent


Return to header index

_10
enum SpContent {
_10
_10
};

Content type.

SpMediaType


Return to header index

_10
enum SpMediaType {
_10
_10
};

Media Type.

SpAudioQuality


Return to header index

_10
enum SpAudioQuality {
_10
_10
};

Audio quality.

SpDrmFormat


Return to header index

_10
enum SpDrmFormat {
_10
kSpDrmFormatUnknown,
_10
kSpDrmFormatUnencrypted,
_10
kSpDrmFormatFairPlay,
_10
kSpDrmFormatWidevine,
_10
kSpDrmFormatPlayReady,
_10
_10
};

DRM formats.

kSpDrmFormatUnknownUnknown DRM.
kSpDrmFormatUnencryptedNo DRM, unencrypted.
kSpDrmFormatFairPlayFairPlay.
kSpDrmFormatWidevineWidevine.
kSpDrmFormatPlayReadyPlayReady.

SpReDeliveryMode


Return to header index

_10
enum SpReDeliveryMode {
_10
_10
};

Redelivery mode types.

SpInit


Return to header index

_10
SpError SpInit(struct SpConfig *conf)

Initialize the library.

SpFree


Return to header index

_10
SpError SpFree(void)

Shut down the library.

If a user is currently logged in, the application should first call SpConnectionLogout() and wait for the kSpConnectionNotifyLoggedOut event, otherwise SpFree() may take several seconds.

SpGetLibraryVersion


Return to header index

_10
const char * SpGetLibraryVersion(void)

Retrieve a version string for the library.

Notes:
  • This API can be invoked from a callback.

SpConnectionSetConnectivity


Return to header index

_10
SpError SpConnectionSetConnectivity(enum SpConnectivity connectivity)

Set the type of network connection of the device.

When the application detects that the device has lost network connection, it should call this function with kSpConnectivityNone. When network connection is restored, the application should call this function with one of the other values of SpConnectivity. The library will then immediately retry to reconnect to Spotify (rather than waiting for the next retry timeout). The library may use the type of network connection to adapt its streaming and buffering strategies. Currently, however, all types of network connection are treated the same.

SpConnectionGetConnectivity


Return to header index

_10
enum SpConnectivity SpConnectionGetConnectivity(void)

Get the connectivity that was set with SpConnectionSetConnectivity()

The library does not detect the type of network connection by itself. It only updates it if the application calls SpConnectionSetConnectivity(). If SpConnectionSetConnectivity() was never called, the connection defaults to kSpConnectivityWired.

Notes:
  • This API can be invoked from a callback.

SpConnectionLoginBlob


Return to header index

_10
SpError SpConnectionLoginBlob(const char *username, const char *credentials_blob)

Log in a user to Spotify using a credentials blob.

See also Notes:
  • The login is performed asynchronously. The return value only indicates whether the library is able to perform the login attempt. The status of the login will be reported via callbacks:
  • The blob can only be used for subsequent logins as long as the value of SpConfig::unique_id does not change. If SpConfig::unique_id has changed since the blob was received, this function returns an error and you will receive a debug message similar to "Parsing ZeroConf blob failed with code -3".

SpConnectionLoginOauthToken


Return to header index

_10
SpError SpConnectionLoginOauthToken(const char *oauth_token)

Log in a user to Spotify using a Spotify OAuth token.

For subsequent logins the SpCallbackConnectionNewCredentials() callback should be implemented and the received credentials blob should be stored and used. (Note that the OAuth access token itself expires after a short time. The credentials blob returned by the callback allows you to re-login even after the token has expired.)

See also Notes:
  • The login is performed asynchronously. The return value only indicates whether the library is able to perform the login attempt. The status of the login will be reported via callbacks:
  • Spotify Connect-enabled hardware devices that implement the ZeroConf stack must use the function SpConnectionLoginBlob() instead.

SpConnectionLogout


Return to header index

_10
SpError SpConnectionLogout(void)

Log the user out of Spotify.

See also Notes:

SpConnectionIsLoggedIn


Return to header index

_10
uint8_t SpConnectionIsLoggedIn(void)

Is the user logged in to Spotify.

See also Notes:
  • This API can be invoked from a callback.

SpConnectionGetAckId


Return to header index

_10
const char * SpConnectionGetAckId(void)

Get the last Ack ID.

Notes:
  • This function is deprecated and should not be used.

SpGetCanonicalUsername


Return to header index

_10
const char * SpGetCanonicalUsername(void)

Get the canonical username of the logged in user.

This function returns the canonical username of the logged in user, which is the unique username used for identifying a specific user for things like playlists and the Spotify Web API. This username might differ from the username used to login. A user can login with an e-mail address or non-canonical unicode. This function will return the canonicalized version of the username after a successful login.

Notes:
  • The canonical username should not be stored persistently. Always store the username as provided by the user, not the canonicalized version.
  • This API can be invoked from a callback.

SpSetDisplayName


Return to header index

_10
SpError SpSetDisplayName(const char *display_name)

Set the display name for the device or application.

This function can be used to change the display name that was passed to SpInit() in the field SpConfig::display_name.

Notes:
  • The display name is not allowed to be an empty string.

SpSetVolumeSteps


Return to header index

_10
SpError SpSetVolumeSteps(uint32_t steps)

Set the volume steps the device is capable of.

This function will indicate the number of intermediate steps from min_volume to max_volume that the device supports. If there's no volume control ability it must be set to zero to inform that no volume control is possible at all. The default number of steps if this function is not called is 16.

Notes:
  • There's no commitment from the other Connect clients to respect the volume steps. It's important to call this function passing zero if no volume control is possible though.

SpSetDeviceIsGroup


Return to header index

_10
SpError SpSetDeviceIsGroup(int is_group)

Control if the device represents a group.

A group is a number of devices all playing back the same sound synchronized. Setting this status correctly will allow Spotify clients to display the correct metadata for this device.

Notes:
  • If device aliases are used, this function should not be used to set the group status. Instead, SpSetDeviceAliases() should be used to update group status individually for each alias.

SpEnableConnect


Return to header index

_10
SpError SpEnableConnect(void)

Enable Connect functionality for this device.

A device with enabled Connect functionality will show up in other devices' Connect pickers, and will be able to both control them and be controlled. The Spotify embedded library will enable Connect functionality by default

SpDisableConnect


Return to header index

_10
SpError SpDisableConnect(void)

Disable Connect functionality for this device.

A device that disables Connect will not be able to control playback on other devices, or be controlled by them.

SpGetSelectedDeviceAlias


Return to header index

_10
int SpGetSelectedDeviceAlias(void)

Return the currently selected device alias.

SpPumpEvents


Return to header index

_10
SpError SpPumpEvents(void)

Allow the library to perform asynchronous tasks and process events.

Note: The suggested time interval to call this function is 10ms. This function should not be called from a callback. A typical usage pattern looks like this:

Example:

_11
int quit=0;
_11
SpInit(&conf);
_11
SpConnectionLoginBlob(username,blob);
_11
while (!quit){
_11
//Processtasksandinvokecallbacks
_11
SpPumpEvents();
_11
//HeretheapplicationshouldupdateitsUIand
_11
//callotherSpotifyEmbeddedAPIsinreaction
_11
//tothecallbackeventsthatitreceived.
_11
};
_11
SpFree();

SpRegisterConnectionCallbacks


Return to header index

_10
SpError SpRegisterConnectionCallbacks(struct SpConnectionCallbacks *cb, void *context)

Register callbacks related to the connection to Spotify.

SpRegisterDebugCallbacks


Return to header index

_10
SpError SpRegisterDebugCallbacks(struct SpDebugCallbacks *cb, void *context)

Register a callback that receives debug messages/trace logs.

These callbacks can be registered before SpInit() has been called, in order to receive debug logs that occur during initialization.

SpRegisterPlaybackCallbacks


Return to header index

_10
SpError SpRegisterPlaybackCallbacks(struct SpPlaybackCallbacks *cb, void *context)

Register playback-related callbacks.

SpGetMetadata


Return to header index

_10
SpError SpGetMetadata(struct SpMetadata *metadata, int relative_index)

Retrieve metadata for a track in the current track list.

Notes:
  • This API can be invoked from a callback.
  • Be aware that many APIs that change the currently playing context are asynchronous, and the changes will not be immediately reflected in the metadata returned by SpGetMetadata(). For example, when calling SpPlaybackSkipToNext(), SpPlaybackEnableShuffle(), etc., the metadata returned by SpGetMetadata() might be unchanged while the command is being processed (which involves network communication). The notification kSpPlaybackNotifyMetadataChanged will be sent as soon as SpGetMetadata() would return a different result for any relative_index defined in the enum SpMetadataTrack.

SpGetMetadataImageURL


Return to header index

_10
SpError SpGetMetadataImageURL(const char *image_uri, char *image_url, size_t image_url_size)

Return the HTTP URL to an image file from a spotify:image: URI.

Notes:
  • This API can be invoked from a callback.

SpGetPlayerCookie


Return to header index

_10
SpError SpGetPlayerCookie(char *player_cookie, size_t player_cookie_size)

Obtain player cookie for current playback.

The obtained player cookie can then be used to get more detailed metadata for current playback from Spotify's backend using Spotify Web API.

Notes:
  • Experimental, subject to change

SpPlaybackPlay


Return to header index

_10
SpError SpPlaybackPlay(int alias_index)

Start or resume playback.

SpPlaybackPause


Return to header index

_10
SpError SpPlaybackPause(void)

Pause playback.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

SpPlaybackSkipToNext


Return to header index

_10
SpError SpPlaybackSkipToNext(void)

Skip playback to the next track in the track list.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

SpPlaybackSkipToPrev


Return to header index

_10
SpError SpPlaybackSkipToPrev(void)

Skip playback to the previous track in the track list.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

Notes:
  • This function will try to skip to the previous track regardless of the current playback position. If the desired behaviour is to only skip to the previous track UNLESS the current playback position is beyond 3 seconds, the following code example is suggested as a base: if(SpPlaybackGetPosition()/1000=3) SpPlaybackSeek(0); else SpPlaybackSkipToPrev();

SpPlaybackSeek


Return to header index

_10
SpError SpPlaybackSeek(uint32_t position_ms)

Seek to a position within the current track.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

SpPlaybackSeekRelative


Return to header index

_10
SpError SpPlaybackSeekRelative(int32_t time_ms)

Seek a relative amount of time within the current track.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

SpPlaybackGetPosition


Return to header index

_10
uint32_t SpPlaybackGetPosition(void)

Get the current playback position within the track.

Notes:
  • This API can be invoked from a callback.

SpPlaybackUpdateVolume


Return to header index

_10
SpError SpPlaybackUpdateVolume(uint16_t volume)

Request a change to the playback volume.

It is the application's responsibility to apply the volume change to its audio output. This function merely notifies the library of the volume change, so that the library can inform other Spotify Connect-enabled devices. Calling this function invokes the SpCallbackPlaybackApplyVolume() callback, which the application can use to apply the actual volume change.

Notes:
  • When the library is initialized, it assumes a volume level of 32768 (50% volume). The application must invoke SpPlaybackUpdateVolume() at some point after calling SpInit() to inform the library of the actual volume level of the device's audio output.

SpPlaybackGetVolume


Return to header index

_10
uint16_t SpPlaybackGetVolume(void)

Get the playback volume level.

This returns the last volume level that the application set using SpPlaybackUpdateVolume() or that was reported to the application using SpCallbackPlaybackApplyVolume().

Notes:
  • This API can be invoked from a callback.

SpPlaybackIsPlaying


Return to header index

_10
uint8_t SpPlaybackIsPlaying(void)

Is the playback status playing or paused.

See also Notes:
  • This API can be invoked from a callback.
  • The result of this API is analogous to the playback notifications kSpPlaybackNotifyPlay and kSpPlaybackNotifyPause.

SpPlaybackIsAdPlaying


Return to header index

_10
uint8_t SpPlaybackIsAdPlaying(void)

Is the current track an Ad or not.

See also
  • kSpPlaybackNotifyTrackChanged
Notes:
  • This API can be invoked from a callback.

SpPlaybackIsShuffled


Return to header index

_10
uint8_t SpPlaybackIsShuffled(void)

Is "shuffle" mode enabled.

See also Notes:
  • This API can be invoked from a callback.

SpPlaybackIsRepeated


Return to header index

_10
uint8_t SpPlaybackIsRepeated(void)

Is "repeat" mode enabled.

See also Notes:
  • This API can be invoked from a callback.

SpPlaybackGetRepeatMode


Return to header index

_10
uint8_t SpPlaybackGetRepeatMode(void)

Which "repeat" mode is on.

See also Notes:
  • This API can be invoked from a callback.

SpPlaybackIsActiveDevice


Return to header index

_10
uint8_t SpPlaybackIsActiveDevice(void)

Is the device the active playback device.

See also
  • kSpPlaybackNotifyBecameActive
  • kSpPlaybackNotifyBecameInactive
Notes:
  • This API can be invoked from a callback.

SpPlaybackEnableShuffle


Return to header index

_10
SpError SpPlaybackEnableShuffle(uint8_t enable)

Enable or disable "shuffle" mode.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

See also Notes:
  • The change to the shuffle mode might not take effect if the API is invoked in the time window between requesting playback of a new context (e.g., by calling SpPlayUri()), and playback of the new context actually starting.

SpPlaybackEnableRepeat


Return to header index

_10
SpError SpPlaybackEnableRepeat(uint8_t enable)

Enable or disable "repeat" mode.

If the device is not the active speaker (SpPlaybackIsActiveDevice()), the error code kSpErrorNotActiveDevice is returned.

See also

SpPlaybackCycleRepeatMode


Return to header index

_10
SpError SpPlaybackCycleRepeatMode(void)

Cycle through the available repeat modes.

Cycles through repeat modes (repeat off, repeat context, repeat track) given their current availability. If for example repeat context is enabled and repeat track is disallowed due to restrictions, this API will go directly to repeat off.

SpPlaybackSetBitrate


Return to header index

_10
SpError SpPlaybackSetBitrate(enum SpPlaybackBitrate bitrate)

Change the bitrate at which compressed audio data is delivered.

The integration will be required to flush the data it has already received at the current audio quality. The data in the new audio quality will then be streamed from the playback position we were at when this API was called.

SpPlaybackSetDeviceInactive


Return to header index

_10
SpError SpPlaybackSetDeviceInactive(void)

Set the device inactive.

If the device is currently the active device, this function stops the playback if playing, sets the device inactive, and sends the notification kSpPlaybackNotifyBecameInactive. If the device is already inactive, the error code kSpErrorNotActiveDevice is returned.

See also Notes:

SpPlaybackIsDeviceControllable


Return to header index

_10
uint8_t SpPlaybackIsDeviceControllable(void)

Is the device controllable.

See also

SpPlaybackSetDeviceControllable


Return to header index

_10
SpError SpPlaybackSetDeviceControllable(uint8_t is_controllable)

Allow or disallow the device to be controllable.

On some platforms, there might be certain situations in which the control of the playback should be disallowed temporarily. In this case, when the user tries to start playback on the device using the mobile application, the device should be marked as "Unavailable for playback" in the UI.

See also Notes:
  • This functionality is reserved for specific integration scenarios. It can be used to temporarily forbid playback when for example playing cutscenes in video games or taking a phone call while driving a car. This API should not be used if the device is unable to play (for example, if a firmware upgrade is about to be performed), the application shall then instead log out, shut down the library, and stop announcing the device via the ZeroConf.

SpPlaybackIncreaseUnderrunCount


Return to header index

_10
SpError SpPlaybackIncreaseUnderrunCount(uint32_t count)

Increase the underrun counter of the current track.

If playback underruns have been detected in the current track, use this API to report it to eSDK. This should only be called when there was no data to play at all and there was an audible glitch or gap for the user. It should only be called if audio was expected to be played and there was audio before. For example if eSDK is active and playing, but there is an underrun, report it. If eSDK is active and was requested to play something, but it never started, do not report it. If eSDK is active and playing and user skips, there is an expected gap, so report an underrun only if audio data started being delivered from eSDK and then stopped.

SpPlaybackSetBandwidthLimit


Return to header index

_10
SpError SpPlaybackSetBandwidthLimit(uint32_t max_bytes_per_sec)

Set a limit on the download speed.

By calling this function eSDK will attempt to limit how fast it downloads a track. In some use cases it is preferred to not use the full bandwidth. At the beginning of a download eSDK will do a burst download and then try to obey the limit.

Notes:
  • eSDK is not guaranteed to stay strictly below the limit but will not exceed it by much. It is also not guaranteed to use all available bandwidth.

SpPlaybackSetRedeliveryMode


Return to header index

_10
SpError SpPlaybackSetRedeliveryMode(SpReDeliveryMode mode)

Activates redelivery of audio data on play or resume playback.

This function should be called to activate or deactivate audio redelivery for the next calls to SpPlaybackPlay(). When the client application can't keep unplayed audio in its playback buffers (for example when audio from some other source was played while Spotify was paused) the eSDK should be notified that redelivery of audio data is needed. The audio data is redelivered from the last playback position reported by the integration with the same precision as seek. eSDK will need to redownload the data that was already delivered to the integration and therefore there will be a penalty of increased data consumption and latencies. Only use this function when unplayed audio is discarded.

SpPlaybackIsRedeliveryModeActivated


Return to header index

_10
SpReDeliveryMode SpPlaybackIsRedeliveryModeActivated(void)

Gets the status of redelivery mode.

When redelivery mode is activated or deactivated through the API SpPlaybackSetRedeliveryMode(), an internal state is updated to keep track of the redelivery behavior. This API exposes this internal state.

SpZeroConfGetVars


Return to header index

_10
SpError SpZeroConfGetVars(struct SpZeroConfVars *vars)

Get variables for ZeroConf, mainly the "getInfo" request.

The application should use this function to retrieve the data that it should send in the response to the "getInfo" request. See the ZeroConf manual for more information. There are also other fields here that might be needed for ZeroConf.

Notes:
  • This API can be invoked from a callback.

SpZeroConfAnnouncePause


Return to header index

_10
SpError SpZeroConfAnnouncePause(void)

Temporarily pause ZeroConf mDNS announcements.

Notes:

SpZeroConfAnnounceResume


Return to header index

_10
SpError SpZeroConfAnnounceResume(void)

Resume ZeroConf mDNS announcement after calling SpZeroConfAnnouncePause()

Notes:

SpConnectionLoginZeroConf


Return to header index

_10
SpError SpConnectionLoginZeroConf(const char *username, const char *zero_conf_blob, const char *client_key, const char *login_id, const char *token_type)

Log in a user to Spotify using a ZeroConf credentials blob.

This function logs in with the information that the application receives in the "addUser" ZeroConf request. See the ZeroConf manual.

See also Notes:
  • The login is performed asynchronously. The return value only indicates whether the library is able to perform the login attempt. The status of the login will be reported via callbacks:

SpGetBrandName


Return to header index

_10
const char * SpGetBrandName(void)

This function can be used to get the brand name. If the field SpConfig::brand_display_name was set at SpInit(), function returns its value, otherwise it returns what was set in the mandatory field SpConfig::brand_name.

Notes:
  • This API can be invoked from a callback.

SpGetModelName


Return to header index

_10
const char * SpGetModelName(void)

This function can be used to get the model name. If the field SpConfig::model_display_name was set at SpInit(), function returns its value, otherwise it returns what was set in the mandatory field SpConfig::model_name.

Notes:
  • This API can be invoked from a callback.

SpRegisterDeviceAliasCallbacks


Return to header index

_10
SpError SpRegisterDeviceAliasCallbacks(struct SpDeviceAliasCallbacks *cb, void *context)

Register callbacks related to device aliases.

SpSetDeviceAliases


Return to header index

_10
SpError SpSetDeviceAliases(const struct SpDeviceAlias *aliases)

Update the device alias definitions.

Call this whenever the current alias definitions are updated. The id values for the aliases must be unique within the array. aliases Pointer to an array of SpDeviceAlias structs filled in with the new alias names and corresponding attributes. The array size must be of size SP_MAX_DEVICE_ALIASES.

SpSetAdUserAgent


Return to header index

_10
SpError SpSetAdUserAgent(const char *user_agent)

Set the ad user agent.

For clients that need to register a specific UserAgent for ads.

See also

SpRestrictDrmMediaFormats


Return to header index

_10
SpError SpRestrictDrmMediaFormats(const struct SpFormat restricted_formats[SP_MAX_SUPPORTED_FORMATS])

Restrict DRM/Media formats.

restricted_formats An array of DRM/media format pairs to restrict. Restricts the list of DRM and media formats to a subset of the formats registered in SpInit(). COMPATIBILITY NOTE: To restore the restricted capabilitites to the ones registered in SpInit() call this API again with a NULL parameter. That is, SpRestoreDrmMediaFormats() is now removed.

See also Notes:
  • This API can be invoked from a callback.
Example:

_10
const struct SpFormat formats[SP_MAX_SUPPORTED_FORMATS];
_10
memset(formats,0, sizeof (formats));
_10
formats[0].drm= kSpDrmFormatUnencrypted;
_10
formats[0].media=
_10
(1 kSpMediaFormatSpotifyOggVorbis)|(1 kSpMediaFormatMp3);
_10
formats[1].drm= kSpDrmFormatFairPlay;
_10
formats[1].media=(1 kSpMediaFormatMp4AAC);

Content



_10
#include "spotify_embedded_content.h"

Data Structures


Return to header index
SpContentCallbacksCallbacks to be registered with SpRegisterContentCallbacks()

Typedefs


Return to header index
SpCallbackTrackCacheStateThis callback, if set by the client, is called by eSDK to inform how many percent of the particular track are cached. It is measured from the beginning of the track. E.g. if 60 is reported it means that 60% of the track is cached starting from the beginning.
SpCallbackStorageKeyContentMappingThis callback, if set by the client, is called by eSDK to notify how the storage_key is mapped to particular content being stored. SpContentType is used to specify exact content type. For example: hint being equal to kSpContentTrack means that the descriptor's representation is spotify:track:[base62].
SpCallbackTrackRelinkedThis callback, if set by the client, is called by eSDK to notify about the fact that requested track is substituted with another (relinked) one during prefetch/offline process.
SpCallbackTrackRemovedThis callback, if set by the client, is called by eSDK to notify that the track is removed.
SpCallbackOnAvailableContainerCallback for each available container.

Enumerations


Return to header index
SpContentTypeEnum describes content type being stored by eSDK.

Functions


Return to header index
SpRegisterContentCallbacks

SpContentCallbacks


Return to header index

_10
struct SpContentCallbacks {
_10
SpCallbackTrackCacheState track_state_callback;
_10
SpCallbackStorageKeyContentMapping store_key_map_callback;
_10
SpCallbackTrackRelinked track_relink_callback;
_10
SpCallbackTrackRemoved track_removed_callback;
_10
SpCallbackOnAvailableContainer on_available_container;
_10
};

Callbacks to be registered with SpRegisterContentCallbacks()

Any of the pointers may be NULL.

Notes:
  • See the documentation of the callback typedefs for information about the individual callbacks.
SpCallbackTrackCacheState track_state_callbackTrack cached state callback.
SpCallbackStorageKeyContentMapping store_key_map_callbackContent mapping callback.
SpCallbackTrackRelinked track_relink_callbackNotify about track relink during prefetch/offline.
SpCallbackTrackRemoved track_removed_callbackNotify about track removal.
SpCallbackOnAvailableContainer on_available_containerNotify about an available container item.

SpCallbackTrackCacheState


Return to header index

_10
typedef void(* SpCallbackTrackCacheState) (const char *track_uri, uint32_t percents, void *context)

This callback, if set by the client, is called by eSDK to inform how many percent of the particular track are cached. It is measured from the beginning of the track. E.g. if 60 is reported it means that 60% of the track is cached starting from the beginning.

Notes:
  • The application should not block or call other API functions in the callback. This callback is called before each track delivery is started.

SpCallbackStorageKeyContentMapping


Return to header index

_10
typedef void(* SpCallbackStorageKeyContentMapping) (const char *storage_key, const char *descriptor, enum SpContentType hint, void *context)

This callback, if set by the client, is called by eSDK to notify how the storage_key is mapped to particular content being stored. SpContentType is used to specify exact content type. For example: hint being equal to kSpContentTrack means that the descriptor's representation is spotify:track:[base62].

See also Notes:
  • The application should not block or call other API functions in the callback. This callback is called as soon as possible after Alloc callback of Storage API has been called and succeeds.

SpCallbackTrackRelinked


Return to header index

_10
typedef void(* SpCallbackTrackRelinked) (const char *original_uri, const char *new_uri, void *context)

This callback, if set by the client, is called by eSDK to notify about the fact that requested track is substituted with another (relinked) one during prefetch/offline process.

SpCallbackTrackRemoved


Return to header index

_10
typedef void(* SpCallbackTrackRemoved) (const char *track_uri, void *context)

This callback, if set by the client, is called by eSDK to notify that the track is removed.

track_uri URI passed into eSDK PlayURI/PrefetchURI/OfflineURI function calls. context Context provided in callback register procedure.

SpCallbackOnAvailableContainer


Return to header index

_10
typedef void(* SpCallbackOnAvailableContainer) (const char *uri, int total, void *context)

Callback for each available container.

Notes:
  • Experimental, subject of change

SpContentType


Return to header index

_10
enum SpContentType {
_10
_10
};

Enum describes content type being stored by eSDK.

SpRegisterContentCallbacks


Return to header index

_10
SpError SpRegisterContentCallbacks(struct SpContentCallbacks *callbacks, void *context)

Hal



_10
#include "spotify_embedded_hal.h"

Data Structures


Return to header index
SpSockaddrStruct contains resolved hostname IP address and its family.
SpDnsHALCallbacksCallbacks to be registered with SpRegisterDnsHALCallbacks()
SpSocketHandleSocket handle type.
SpSocketHALCallbacksCallbacks to be registered with SpRegisterSocketHALCallbacks()

Typedefs


Return to header index
SpCallbackPerformDNSLookupThis callback, if set by the client, is called by eSDK to perform DNS lookups. It should be robust against slow name resolutions (e.g. poor network conditions) by performing lookups asynchronously. Otherwise SpPumpEvents() might block for too long and cause audio stutters. See documentation for return value for more recommendations w.r.t. asynchronous implementation.
SpCallbackSocketCreateThis callback, if set by the client, is called by eSDK to create a socket of a certain type and family.
SpCallbackSocketSetOptionThis callback, if set by the client, is called by eSDK to set specific options on the previously created socket.
SpCallbackSocketCloseThis callback, if set by the client, is called by eSDK to close the previously opened socket.
SpCallbackSocketBindThis callback, if set by the client, is called by eSDK to bind to the provided socket.
SpCallbackSocketListenThis callback, if set by the client, is called by eSDK to start listening on the provided socket. This callback has no effect on UDP sockets.
SpCallbackSocketConnectThis callback, if set by the client, is called by eSDK to connect to the specified address and remote port.
SpCallbackSocketAcceptThis callback, if set by the client, is called by eSDK to accept connection on the provided socket.
SpCallbackSocketReadThis callback, if set by the client, is called by eSDK to read data from the socket.
SpCallbackSocketWriteThis callback, if set by the client, is called by eSDK to write data to the socket.
SpCallbackSocketReadFromThis callback, if set by the client, is called by eSDK to read data from the socket addressed by the SpSockaddr instance.
SpCallbackSocketWriteToThis callback, if set by the client, is called by eSDK to write data to the socket addressed by the SpSockaddr instance.
SpCallbackSocketErrorThis callback, if set by the client, is called by eSDK to get the underlying OS error code.
SpCallbackSocketReadableThis callback, if set by the client, is called by eSDK to figure out if the socket is readable.
SpCallbackSocketWriteableThis callback, if set by the client, is called by eSDK to figure out if the socket is writable.
SpCallbackLocalAddressesThis callback, if set by the client, is called by eSDK to get local interface addresses.
SpCallbackSocketAddressThis callback, if set by the client, is called by eSDK to provide platform defined representation of address that can be used in SpCallbackSocketReadFrom() and SpCallbackSocketWriteTo(). The client is responsible for providing a sufficient lifetime of the returned pointer.
SpCallbackPumpThis callback, if set by the client, is called by eSDK to pump the network layer.

Enumerations


Return to header index
SpIPFamilyEnum describes the IP family.
SpSocketPoolSocket pool IDs.
SpSocketTypeEnum defines the type of socket supported by eSDK.
SpSocketOptionsEnum defines options that can be applied to sockets.

Functions


Return to header index
SpRegisterDnsHALCallbacksRegister HAL-related callbacks. Should be called right after SpInit().
SpGetDefaultDnsHALCallbacksGet eSDK's default DNS callbacks.
SpRegisterSocketHALCallbacksRegister socket HAL-related callbacks. To remove callbacks, call SpRegisterSocketHALCallbacks() with SpSocketHALCallbacks initialized to zeros.
SpGetDefaultSocketHALCallbacksGet eSDK's default socket callbacks.

SpSockaddr


Return to header index

_10
struct SpSockaddr {
_10
enum SpIPFamily family;
_10
uint8_t addr;
_10
int port;
_10
};

Struct contains resolved hostname IP address and its family.

enum SpIPFamily familyIP protocol family for which lookup is requested.
uint8_t addrIp address. Network byte order.
int portContains port value if applicable. Host byte order.

SpDnsHALCallbacks


Return to header index

_10
struct SpDnsHALCallbacks {
_10
SpCallbackPerformDNSLookup dns_lookup_callback;
_10
};

Callbacks to be registered with SpRegisterDnsHALCallbacks()

Any of the pointers may be NULL. To remove DNS callback at any time call SpRegisterDnsHALCallbacks() with SpDnsHALCallbacks::dns_lookup_callback set to NULL.

Notes:
  • See the documentation of the callback typedefs for information about the individual callbacks.
SpCallbackPerformDNSLookup dns_lookup_callbackDNS lookup callback. If NULL eSDK will use its internal DNS resolve mechanism.

SpSocketHandle


Return to header index

_10
struct SpSocketHandle {
_10
void *handle;
_10
void *tls;
_10
};

Socket handle type.

void * handlePlatform defined socket representation.
void * tlsCan be used by the TLS implementation to store connection specific state.

SpSocketHALCallbacks


Return to header index

_19
struct SpSocketHALCallbacks {
_19
SpCallbackSocketCreate socket_create;
_19
SpCallbackSocketSetOption socket_set_option;
_19
SpCallbackSocketClose socket_close;
_19
SpCallbackSocketBind socket_bind;
_19
SpCallbackSocketListen socket_listen;
_19
SpCallbackSocketConnect socket_connect;
_19
SpCallbackSocketAccept socket_accept;
_19
SpCallbackSocketRead socket_read;
_19
SpCallbackSocketWrite socket_write;
_19
SpCallbackSocketReadFrom socket_read_from;
_19
SpCallbackSocketWriteTo socket_write_to;
_19
SpCallbackSocketError socket_error;
_19
SpCallbackSocketReadable socket_readable;
_19
SpCallbackSocketWriteable socket_writable;
_19
SpCallbackLocalAddresses local_addresses;
_19
SpCallbackSocketAddress socket_address;
_19
SpCallbackPump on_pump;
_19
};

Callbacks to be registered with SpRegisterSocketHALCallbacks()

Any of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackSocketCreate socket_createCallback to create socket instance.
SpCallbackSocketSetOption socket_set_optionCallback to set options on created socket.
SpCallbackSocketClose socket_closeCallback to close the socket.
SpCallbackSocketBind socket_bindCallback to bind to socket.
SpCallbackSocketListen socket_listenCallback to start listening the socket.
SpCallbackSocketConnect socket_connectCallback to connect to socket.
SpCallbackSocketAccept socket_acceptCallback to accept connection on socket.
SpCallbackSocketRead socket_readCallback to read data from socket.
SpCallbackSocketWrite socket_writeCallback to write data to socket.
SpCallbackSocketReadFrom socket_read_fromCallback to read data from socket pointed by address.
SpCallbackSocketWriteTo socket_write_toCallback to write data to socket pointed by address.
SpCallbackSocketError socket_errorCallback to get OS error on socket.
SpCallbackSocketReadable socket_readableCallback to get readable state on socket.
SpCallbackSocketWriteable socket_writableCallback to get writable state on socket.
SpCallbackLocalAddresses local_addressesCallback to get local interface addresses.
SpCallbackSocketAddress socket_addressCallback to platform address representation.
SpCallbackPump on_pumpCallback to pump network layer.

SpCallbackPerformDNSLookup


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackPerformDNSLookup) (const char *hostname, struct SpSockaddr *sockaddr, void *context)

This callback, if set by the client, is called by eSDK to perform DNS lookups. It should be robust against slow name resolutions (e.g. poor network conditions) by performing lookups asynchronously. Otherwise SpPumpEvents() might block for too long and cause audio stutters. See documentation for return value for more recommendations w.r.t. asynchronous implementation.

See also Notes:
  • See SpRegisterDnsHALCallbacks() for recommendation when it makes sense to provide a custom DNS callback.
  • The application should not block or call other API functions in the callback.

SpCallbackSocketCreate


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketCreate) (enum SpIPFamily family, enum SpSocketType type, enum SpSocketPool pool_id, struct SpSocketHandle **socket, void *context)

This callback, if set by the client, is called by eSDK to create a socket of a certain type and family.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketSetOption


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketSetOption) (struct SpSocketHandle *socket, enum SpSocketOptions option, void *value, void *context)

This callback, if set by the client, is called by eSDK to set specific options on the previously created socket.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketClose


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketClose) (struct SpSocketHandle *socket, void *context)

This callback, if set by the client, is called by eSDK to close the previously opened socket.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketBind


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketBind) (struct SpSocketHandle *socket, int *port, void *context)

This callback, if set by the client, is called by eSDK to bind to the provided socket.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketListen


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketListen) (struct SpSocketHandle *socket, int backlog, void *context)

This callback, if set by the client, is called by eSDK to start listening on the provided socket. This callback has no effect on UDP sockets.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketConnect


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketConnect) (struct SpSocketHandle *socket, const struct SpSockaddr *addr, void *context)

This callback, if set by the client, is called by eSDK to connect to the specified address and remote port.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketAccept


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketAccept) (struct SpSocketHandle *socket, enum SpSocketPool pool_id, struct SpSocketHandle **out_socket, void *context)

This callback, if set by the client, is called by eSDK to accept connection on the provided socket.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketRead


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketRead) (struct SpSocketHandle *socket, void *data, int data_size, int *bytes_read, void *context)

This callback, if set by the client, is called by eSDK to read data from the socket.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketWrite


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketWrite) (struct SpSocketHandle *socket, const void *data, int data_size, int *bytes_written, void *context)

This callback, if set by the client, is called by eSDK to write data to the socket.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketReadFrom


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketReadFrom) (struct SpSocketHandle *socket, void *data, int data_size, const void **addr, int *bytes_read, void *context)

This callback, if set by the client, is called by eSDK to read data from the socket addressed by the SpSockaddr instance.

Notes:
  • The application should not block or call other API functions in the callback. This callback should mirror the behavior of recvfrom() for connected/non-connected sockets.

SpCallbackSocketWriteTo


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackSocketWriteTo) (struct SpSocketHandle *socket, const void *data, int data_size, const void *addr, int *bytes_written, void *context)

This callback, if set by the client, is called by eSDK to write data to the socket addressed by the SpSockaddr instance.

Notes:
  • The application should not block or call other API functions in the callback. This callback should mirror the behavior of sendto() for connected/non-connected sockets.

SpCallbackSocketError


Return to header index

_10
typedef int(* SpCallbackSocketError) (struct SpSocketHandle *socket, void *context)

This callback, if set by the client, is called by eSDK to get the underlying OS error code.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketReadable


Return to header index

_10
typedef int(* SpCallbackSocketReadable) (struct SpSocketHandle *socket, void *context)

This callback, if set by the client, is called by eSDK to figure out if the socket is readable.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketWriteable


Return to header index

_10
typedef int(* SpCallbackSocketWriteable) (struct SpSocketHandle *socket, void *context)

This callback, if set by the client, is called by eSDK to figure out if the socket is writable.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackLocalAddresses


Return to header index

_10
typedef void(* SpCallbackLocalAddresses) (struct SpSockaddr *addrs, int *num_addrs, void *context)

This callback, if set by the client, is called by eSDK to get local interface addresses.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackSocketAddress


Return to header index

_10
typedef const void *(* SpCallbackSocketAddress) (const struct SpSockaddr *addr, void *context)

This callback, if set by the client, is called by eSDK to provide platform defined representation of address that can be used in SpCallbackSocketReadFrom() and SpCallbackSocketWriteTo(). The client is responsible for providing a sufficient lifetime of the returned pointer.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackPump


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackPump) (unsigned max_wait_ms, void *context)

This callback, if set by the client, is called by eSDK to pump the network layer.

Notes:
  • The application should not block or call other API functions in the callback.

SpIPFamily


Return to header index

_10
enum SpIPFamily {
_10
_10
};

Enum describes the IP family.

SpSocketPool


Return to header index

_10
enum SpSocketPool {
_10
_10
};

Socket pool IDs.

SpSocketType


Return to header index

_10
enum SpSocketType {
_10
_10
};

Enum defines the type of socket supported by eSDK.

SpSocketOptions


Return to header index

_10
enum SpSocketOptions {
_10
_10
};

Enum defines options that can be applied to sockets.

SpRegisterDnsHALCallbacks


Return to header index

_10
SpError SpRegisterDnsHALCallbacks(struct SpDnsHALCallbacks *callbacks, void *context)

Register HAL-related callbacks. Should be called right after SpInit().

Notes:
  • To remove DNS callback at any time call SpRegisterDnsHALCallbacks() with SpDnsHALCallbacks::dns_lookup_callback set to NULL.
  • eSDK provides built-in implementation for DNS lookups. For integrations built with glibc = 2.2.3 DNS lookups will be implemented via getaddrinfo_a() and therefore will be done asynchronously. Such integrations have to link libanl (-lanl). Remaining builds will use blocking DNS lookups (e.g. getaddrinfo() for POSIX). Depending on the platform's timeout settings they might cause SpPumpEvents() to block for a long time and result in audio stutters. For affected platforms it's recommended to provide an asynchronous implementation instead.

SpGetDefaultDnsHALCallbacks


Return to header index

_10
SpError SpGetDefaultDnsHALCallbacks(struct SpDnsHALCallbacks *callbacks)

Get eSDK's default DNS callbacks.

Notes:

SpRegisterSocketHALCallbacks


Return to header index

_10
SpError SpRegisterSocketHALCallbacks(struct SpSocketHALCallbacks *callbacks, void *context)

Register socket HAL-related callbacks. To remove callbacks, call SpRegisterSocketHALCallbacks() with SpSocketHALCallbacks initialized to zeros.

Notes:

SpGetDefaultSocketHALCallbacks


Return to header index

_10
SpError SpGetDefaultSocketHALCallbacks(struct SpSocketHALCallbacks *callbacks, void **context)

Get eSDK's default socket callbacks.

Notes:

Log



_10
#include "spotify_embedded_log.h"

Macros and Constants


Return to header index
SP_FILE_NAMEFILE
SP_LOG_DEFAULT_LEVELSP_LOG_LEVEL_INFO
SP_LOG_DEFINE_TRACE_OBJstruct
SP_LOG_DECLARE_TRACE_OBJextern struct
SP_LOG_REGISTER_TRACE_OBJSee macro below
SP_LOGSee macro below
SpLogFatalSee macro below
SpLogErrorSee macro below
SpLogWarning
SpLogInfoSee macro below
SpLogDebugSee macro below
SpLogTraceSee macro below

Data Structures


Return to header index
SpLogTraceObjectTrace object.

Enumerations


Return to header index
SpLogLevelLog levels.

Functions


Return to header index
SpLogRegisterTraceObjectRegister a defined trace object with eSDK.
SpLogOutput a debug message via eSDK.
SpLogSetLevelControl the current logging level.
SpLogGetLevelsGet registered trace objects and log levels.

SP_FILE_NAME


Return to header index

_10
#define SP_FILE_NAME __FILE__

Preferred macro to log the file name, you might redefine SP_FILE_NAME using basename() or use -ffile-prefix-map.

SP_LOG_DEFAULT_LEVEL


Return to header index

_10
#define SP_LOG_DEFAULT_LEVEL SP_LOG_LEVEL_INFO

Default trace log level.

SP_LOG_DEFINE_TRACE_OBJ


Return to header index

_10
#define SP_LOG_DEFINE_TRACE_OBJ struct

Macro to define a trace object.

obj Name of the trace object

SP_LOG_DECLARE_TRACE_OBJ


Return to header index

_10
#define SP_LOG_DECLARE_TRACE_OBJ extern struct

Macro to declare a previously defined trace object.

obj Name of the trace object

SP_LOG_REGISTER_TRACE_OBJ


Return to header index

_10
#define SP_LOG_REGISTER_TRACE_OBJ SpLogRegisterTraceObject(&trace_obj_##obj)

Macro to register a previously defined trace object.

obj Name of the trace object

SP_LOG


Return to header index

_10
#define SP_LOG do { \
_10
if (trace_obj_##obj.level >= lvl) { \

Macro that outputs a trace message.

obj Trace object name lvl Trace level for the message file Source file name func Calling function name line Line number in the source file

SpLogFatal


Return to header index

_10
#define SpLogFatal SP_LOG(obj, SP_LOG_LEVEL_FATAL, SP_FILE_NAME, __func__, __LINE__, __VA_ARGS__)

Emit trace message with SP_LOG_LEVEL_FATAL.

SpLogError


Return to header index

_10
#define SpLogError SP_LOG(obj, SP_LOG_LEVEL_ERROR, SP_FILE_NAME, __func__, __LINE__, __VA_ARGS__)

Emit trace message with SP_LOG_LEVEL_ERROR.

SpLogWarning


Return to header index

_10
#define SpLogWarning

Emit trace message with SP_LOG_LEVEL_WARNING.

SpLogInfo


Return to header index

_10
#define SpLogInfo SP_LOG(obj, SP_LOG_LEVEL_INFO, SP_FILE_NAME, __func__, __LINE__, __VA_ARGS__)

Emit trace message with SP_LOG_LEVEL_INFO.

SpLogDebug


Return to header index

_10
#define SpLogDebug SP_LOG(obj, SP_LOG_LEVEL_DEBUG, SP_FILE_NAME, __func__, __LINE__, __VA_ARGS__)

Emit trace message with SP_LOG_LEVEL_DEBUG.

SpLogTrace


Return to header index

_10
#define SpLogTrace SP_LOG(obj, SP_LOG_LEVEL_TRACE, SP_FILE_NAME, __func__, __LINE__, __VA_ARGS__)

Emit trace message with SP_LOG_LEVEL_TRACE.

SpLogTraceObject


Return to header index

_10
struct SpLogTraceObject {
_10
SpLogLevel level;
_10
const char *name;
_10
};

Trace object.

The trace object is an abstraction of a specific trace message category and an associated log level. The level can be changed freely for individual trace objects.

SpLogLevel levelThe current debug level for this trace object.
const char * nameThe trace category name describing this trace object.

SpLogLevel


Return to header index

_10
enum SpLogLevel {
_10
_10
};

Log levels.

These are the log levels assigned to log messages emitted by the eSDK.

See also

SpLogRegisterTraceObject


Return to header index

_10
SpError SpLogRegisterTraceObject(struct SpLogTraceObject *obj)

Register a defined trace object with eSDK.

SpLog


Return to header index

_10
void SpLog(const struct SpLogTraceObject *obj, SpLogLevel level, const char *file, const char *func, int line, const char *format,...)

Output a debug message via eSDK.

obj Pointer to trace object level The log level associated this this message file The source file from where the call is made, see SP_FILE_NAME. func The function name from where the call is made, typically func. line The line number from where the call is made, typically LINE. format A printf style format string followed by arguments.

SpLogSetLevel


Return to header index

_10
SpError SpLogSetLevel(const char *category, SpLogLevel level)

Control the current logging level.

Control the logging level for a particular category. If the current configured log level is greater than or equal to the level associated with the message, the log message will be passed to the debug log callback. Each log message is also associated with a category. The category is a string that is included in the log message output. Each individual category has a separate current log level. The log messages produced by the eSDK are formatted as: LEVEL CATEGORY MESSAGE where LEVEL is a single letter indicating the log level (E=Error, I=Info, etc.), CATEGORY is a short string that identifies the log category, for example 'api' and MESSAGE is the actual debug message. As an example, a debug output string with level set to SP_LOG_LEVEL_ERROR (letter "E") and the category "api" could look something like this (the timestamp is not actually part of the debug message from eSDK, but added by the SpCallbackDebugMessage(). Therefore, the format may not exactly match the example below).

Example:

_10
12:01:02.000EapiInvalidparameterpassedtoSpInit()

SpLogGetLevels


Return to header index

_10
SpError SpLogGetLevels(char *buffer, int buffer_len)

Get registered trace objects and log levels.

The information about trace objects and levels is represented as a string containing comma separated tuples level:trace obj, e.g. "4:app,4:esdk,4:audio".

Media



_10
#include "spotify_embedded_media.h"

Data Structures


Return to header index
SpStreamInfoStream Parameters.
SpStreamCallbacksCallbacks to be registered with SpRegisterStreamCallbacks()

Typedefs


Return to header index
SpCallbackStreamStartCallback to provide track details to the application.
SpCallbackStreamDataCallback for delivering data to the integration.
SpCallbackStreamEndCallback to tell integration that all data was delivered.
SpCallbackStreamGetPositionCallback to get the playback position in milliseconds.
SpCallbackStreamSeekToPositionCallback to tell the integration to seek to a position.
SpCallbackStreamFlushCallback to tell the integration to flush.

Enumerations


Return to header index
SpMediaFormatMedia formats.

Functions


Return to header index
SpRegisterStreamCallbacksRegister callbacks related to the delivery API.
SpNotifySeekCompleteAPI to notify eSDK of the completion of seek operation.
SpNotifyTrackLengthAPI to notify eSDK of the track length in milliseconds.
SpNotifyTrackErrorAPI to notify eSDK of any track errors with last played position.
SpNotifyStreamPlaybackStartedNotify eSDK that the first audio sample of the delivery has been played.
SpNotifyStreamPlaybackContinuedNotify eSDK that the first audio sample after a flush of a delivery has been played.
SpNotifyStreamPlaybackFinishedNaturallyNotify eSDK that the delivery playback finished by playing the last sample of the delivery.
SpSetDownloadPositionAPI to instruct eSDK to start downloading from a given byte offset.

SpStreamInfo


Return to header index

_10
struct SpStreamInfo {
_10
uint32_t size;
_10
int32_t gain_mdb;
_10
uint32_t start_position_ms;
_10
const char *track_uri;
_10
const char *resource;
_10
};

Stream Parameters.

uint32_t sizeSize of the stream in bytes. If the size is unknown, 0 is used.
int32_t gain_mdbAudio normalization gain (in mdB) to apply to the stream.
uint32_t start_position_msReserved for internal use.
const char * track_uriSpotify track URI.
const char * resourceReserved for internal use.

SpStreamCallbacks


Return to header index

_10
struct SpStreamCallbacks {
_10
SpCallbackStreamStart on_start;
_10
SpCallbackStreamData on_data;
_10
SpCallbackStreamEnd on_end;
_10
SpCallbackStreamGetPosition on_get_position;
_10
SpCallbackStreamSeekToPosition on_seek_position;
_10
SpCallbackStreamFlush on_flush;
_10
};

Callbacks to be registered with SpRegisterStreamCallbacks()

SpCallbackStreamStart on_startStart of delivery callback.
SpCallbackStreamData on_dataData delivery callback.
SpCallbackStreamEnd on_endEnd of delivery callback.
SpCallbackStreamGetPosition on_get_positionCurrent playback position callback.
SpCallbackStreamSeekToPosition on_seek_positionSeek to position callback.
SpCallbackStreamFlush on_flushFlush callback.

SpCallbackStreamStart


Return to header index

_10
typedef void(* SpCallbackStreamStart) (unsigned int stream_id, enum SpMediaFormat media_format, enum SpDrmFormat drm_format, const struct SpStreamInfo *stream_info, void *context)

Callback to provide track details to the application.

To register this callback, use the function SpRegisterStreamCallbacks().

See also

SpCallbackStreamData


Return to header index

_10
typedef size_t(* SpCallbackStreamData) (unsigned int stream_id, const void *buf, size_t len, uint32_t offset, void *context)

Callback for delivering data to the integration.

To register this callback, use the function SpRegisterStreamCallbacks(). This callback is called up to 4 times in a single pump until the integration accepts data less than buffer length or when all data from the download buffer is exhausted.

SpCallbackStreamEnd


Return to header index

_10
typedef void(* SpCallbackStreamEnd) (unsigned int stream_id, void *context)

Callback to tell integration that all data was delivered.

To register this callback, use the function SpRegisterStreamCallbacks(). stream_id Unique identifier to identify tracks context Context pointer that was passed when registering the callback

SpCallbackStreamGetPosition


Return to header index

_10
typedef uint32_t(* SpCallbackStreamGetPosition) (unsigned int stream_id, void *context)

Callback to get the playback position in milliseconds.

To register this callback, use the function SpRegisterStreamCallbacks().

SpCallbackStreamSeekToPosition


Return to header index

_10
typedef void(* SpCallbackStreamSeekToPosition) (unsigned int stream_id, uint32_t position_ms, void *context)

Callback to tell the integration to seek to a position.

To register this callback, use the function SpRegisterStreamCallbacks(). When receiving this callback, the integration should start to seek to the given position. The integration is expected to call SpSetDownloadPosition() to instruct eSDK to start downloading from a byte offset corresponding to the position given in this callback. If the position exceeds the length of the track the integration is expected to seek as close as possible to the end. stream_id Unique identifier to identify tracks position_ms Position in time within the track where to seek to context Context pointer that was passed when registering the callback

SpCallbackStreamFlush


Return to header index

_10
typedef uint32_t(* SpCallbackStreamFlush) (unsigned int *playing_stream_id, void *context)

Callback to tell the integration to flush.

To register this callback, use the function SpRegisterStreamCallbacks(). When receiving this callback, the integration should forget all queued audio and compressed data.

SpMediaFormat


Return to header index

_10
enum SpMediaFormat {
_10
_10
};

Media formats.

SpRegisterStreamCallbacks


Return to header index

_10
SpError SpRegisterStreamCallbacks(struct SpStreamCallbacks *cb, void *context)

Register callbacks related to the delivery API.

SpNotifySeekComplete


Return to header index

_10
SpError SpNotifySeekComplete(unsigned int stream_id)

API to notify eSDK of the completion of seek operation.

SpNotifyTrackLength


Return to header index

_10
SpError SpNotifyTrackLength(unsigned int stream_id, uint32_t length_ms)

API to notify eSDK of the track length in milliseconds.

SpNotifyTrackError


Return to header index

_10
SpError SpNotifyTrackError(unsigned int stream_id, uint32_t position_ms, const char *reason)

API to notify eSDK of any track errors with last played position.

SpNotifyStreamPlaybackStarted


Return to header index

_10
SpError SpNotifyStreamPlaybackStarted(unsigned int stream_id)

Notify eSDK that the first audio sample of the delivery has been played.

This is used by the eSDK to measure playback latency.

SpNotifyStreamPlaybackContinued


Return to header index

_10
SpError SpNotifyStreamPlaybackContinued(unsigned int stream_id)

Notify eSDK that the first audio sample after a flush of a delivery has been played.

This is used by the eSDK to measure seek latency.

SpNotifyStreamPlaybackFinishedNaturally


Return to header index

_10
SpError SpNotifyStreamPlaybackFinishedNaturally(unsigned int stream_id, uint32_t last_pos_ms)

Notify eSDK that the delivery playback finished by playing the last sample of the delivery.

SpSetDownloadPosition


Return to header index

_10
SpError SpSetDownloadPosition(unsigned int stream_id, uint32_t byte_offset)

API to instruct eSDK to start downloading from a given byte offset.

Play



_10
#include "spotify_embedded_play_api.h"

Macros and Constants


Return to header index
SP_NO_INDEX-1
SP_MAX_UUID_LENGTH36
SP_MAX_SOURCE_TYPE_LENGTH63
SP_MAX_SOURCE_URI_LENGTH511
SP_MAX_REFERRER_LENGTH16
SP_PLAYOPTIONS_INITIALIZER_LOGGING_PARAMSInternal macro.
SP_PLAYOPTIONS_INITIALIZERSee macro below

Data Structures


Return to header index
SpSourceInfoMetadata for identifying where a playback request originated from.
SpPlayOptionsPlayOptions passed to SpPlayUriWithOptions(). Use SP_PLAYOPTIONS_INITIALIZER for initializing with default values.

Functions


Return to header index
SpPlayUriStart local playback of the given Spotify URI.
SpPlayUriWithOptionsStart local playback of the given Spotify URI with additional options.
SpPlayContextUriStart local playback of the given Spotify URI with an optional track UID.
SpQueueUriQueue a URI. The track will be in queue only after kSpPlaybackNotifyQueuedTrackAccepted event is raised, but for UI purposes one can choose to monitor for kSpPlaybackNotifyMetadataChanged instead.
SpPlaybackBecomeActiveDeviceBecome active without starting to play.

SP_NO_INDEX


Return to header index

_10
#define SP_NO_INDEX -1

Indicates that the index value is not set. Note: Can only be used with eSDK 3.

See also

SP_MAX_UUID_LENGTH


Return to header index

_10
#define SP_MAX_UUID_LENGTH 36

Maximum length of a UUID.

A 128 bit UUID containing 32 hexadecimal digits in five groups separated by hyphens.

SP_MAX_SOURCE_TYPE_LENGTH


Return to header index

_10
#define SP_MAX_SOURCE_TYPE_LENGTH 63

Maximum length of the type of playback source.

See also

SP_MAX_SOURCE_URI_LENGTH


Return to header index

_10
#define SP_MAX_SOURCE_URI_LENGTH 511

Maximum length of the source URIs.

See also

SP_MAX_REFERRER_LENGTH


Return to header index

_10
#define SP_MAX_REFERRER_LENGTH 16

Maximum length of the referrer.

See also

SP_PLAYOPTIONS_INITIALIZER_LOGGING_PARAMS


Return to header index

_10
#define SP_PLAYOPTIONS_INITIALIZER_LOGGING_PARAMS

Internal macro.

See also

SP_PLAYOPTIONS_INITIALIZER


Return to header index

_10
#define SP_PLAYOPTIONS_INITIALIZER { \
_10
/*.from_index =*/

Macro for initialization of struct SpPlayOptions. Use it instead of memset() due to the fact that some fields are optional and encoded as non-zero values.

SpSourceInfo


Return to header index

_10
struct SpSourceInfo {
_10
char type;
_10
char uri;
_10
char expected_track_uri;
_10
char referrer;
_10
};

Metadata for identifying where a playback request originated from.

See also
char typeThe type of playlist/context/UI view that caused this playback to start. Note: If set, this MUST be one of the following strings (unless told otherwise):
char uriThe URI of the parent container, if there is one.
char expected_track_uriThe URI of the track that is expected to play.
char referrerThe view you were in prior to initiating playback.

SpPlayOptions


Return to header index

_10
struct SpPlayOptions {
_10
int from_index;
_10
const char *from_uid;
_10
int offset_ms;
_10
int shuffle_context;
_10
int repeat_mode;
_10
const struct SpSourceInfo *source_info;
_10
};

PlayOptions passed to SpPlayUriWithOptions(). Use SP_PLAYOPTIONS_INITIALIZER for initializing with default values.

Example:

_10
struct SpPlayOptionsoptions= SP_PLAYOPTIONS_INITIALIZER;

int from_indexTrack index in the Context from which playback should start. Use SP_NO_INDEX if no specific index is required. In case of non-shuffled context this will result in the first track of the context being played whereas in shuffled context this will result in a random track being played.
const char * from_uidThe UID to identify a unique track in the context.
int offset_msThe time offset to start playing specified track from.
int shuffle_contextSet to enable or disable shuffle mode for the requested playback command.
int repeat_modeSet to enable or disable repeat mode for the requested playback command.
const struct SpSourceInfo * source_infoMetadata about what user action caused this playback event, and the expected result.

SpPlayUri


Return to header index

_10
SpError SpPlayUri(const char *uri, int index, int offset_ms, const struct SpSourceInfo *source, int alias_index)

Start local playback of the given Spotify URI.

This call starts playback of a Spotify URI, such as a playlist, album, artist, or track. Valid Spotify URIs can be obtained via the Spotify Web API. Using this call will 'pull' playback from any other Spotify Connect client active on the same account. Note that there may be a lag between the introduction of new URI types and support for playing them with this call.

See also

SpPlayUriWithOptions


Return to header index

_10
SpError SpPlayUriWithOptions(const char *uri, const struct SpPlayOptions *opts, int alias_index)

Start local playback of the given Spotify URI with additional options.

SpPlayContextUri


Return to header index

_10
SpError SpPlayContextUri(const char *uri, const char *from_uid, int offset_ms, const struct SpSourceInfo *source, int alias_index)

Start local playback of the given Spotify URI with an optional track UID.

This call will start playback of any Spotify context URI. In addition, it allows the client to provide a UID to start the playback from a given track in the context. The main difference between UIDs and the field SpSourceInfo::expected_track_uri is that while one track URI can occur more than once in the context, UIDs are unique for each track in it. Valid Spotify URIs can be obtained via the Spotify Web API. Track UIDs are currently available when resolving contexts from a small subset of services. Using this call will 'pull' playback from any other Spotify Connect client active on the same account.

See also

SpQueueUri


Return to header index

_10
SpError SpQueueUri(const char *uri)

Queue a URI. The track will be in queue only after kSpPlaybackNotifyQueuedTrackAccepted event is raised, but for UI purposes one can choose to monitor for kSpPlaybackNotifyMetadataChanged instead.

See also
  • kSpPlaybackNotifyQueuedTrackAccepted
  • kSpErrorInvalidRequest

SpPlaybackBecomeActiveDevice


Return to header index

_10
SpError SpPlaybackBecomeActiveDevice(int alias_index)

Become active without starting to play.

alias_index The index of the device alias that should become active. If aliases aren't used, pass SP_NO_ALIAS_SELECTED. This call makes the device active, without starting to play anything, if playback is paused or no device is active. The device is active after the kSpPlaybackNotifyBecameActive event is received. If another Connect-enabled device was active and playing, it will be interrupted. If the currently active device is playing, this call behaves like SpPlaybackPlay(). If device aliases are used, this function will switch the selected alias. If the selected alias was changed during playback, the playback will continue uninterrupted with the new alias.

Storage



_10
#include "spotify_embedded_storage.h"

Data Structures


Return to header index
SpDiskStorageCallbacksCallbacks to be registered with SpRegisterStorageCallbacks()

Typedefs


Return to header index
SpCallbackStorageAllocCallback to allocate space for the resource being stored. Each successful alloc call is accompanied with a corresponding close call. It is obligatory for the user to use this callback to reserve actual space on device media for the key specified.
SpCallbackStorageWriteCallback for writing the data into storage. Before writing to the storage eSDK does one of two things: call alloc to reserve space for future write or call read to get the data. After that eSDK writes the data into storage. Once write is fully complete eSDK calls close callback.
SpCallbackStorageReadCallback for reading the data. Once eSDK reads all required data, the close callback is called to notify the user that the data handle referenced by storage_key can be closed.
SpCallbackStorageCloseCallback to inform the user that the data handle referenced by storage_key can be closed.
SpCallbackStorageDeleteCallback to inform the user that data referenced by storage_key should be deleted from storage.
SpCallbackThrottleRequesteSDK calls this callback to figure out if it needs to limit write access to the storage.

Functions


Return to header index
SpRegisterStorageCallbacksRegister storage callbacks.

SpDiskStorageCallbacks


Return to header index

_10
struct SpDiskStorageCallbacks {
_10
SpCallbackStorageAlloc alloc_storage;
_10
SpCallbackStorageWrite write_storage;
_10
SpCallbackStorageRead read_storage;
_10
SpCallbackStorageClose close_storage;
_10
SpCallbackStorageDelete delete_storage;
_10
SpCallbackThrottleRequest throttle_request;
_10
};

Callbacks to be registered with SpRegisterStorageCallbacks()

Storage callbacks must be either all NULLs or all valid pointers. Throttle callback may be NULL regardless of storage callbacks. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackStorageAlloc alloc_storageAlloc storage record callback.
SpCallbackStorageWrite write_storageWrite storage data callback.
SpCallbackStorageRead read_storageRead storage data callback.
SpCallbackStorageClose close_storageClose storage record callback.
SpCallbackStorageDelete delete_storageDelete storage record callback.
SpCallbackThrottleRequest throttle_requestAsks the client if disk writes need to be throttled.

SpCallbackStorageAlloc


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackStorageAlloc) (const char *storage_key, uint32_t total_size, void *context)

Callback to allocate space for the resource being stored. Each successful alloc call is accompanied with a corresponding close call. It is obligatory for the user to use this callback to reserve actual space on device media for the key specified.

To register this callback, use the function SpRegisterStorageCallbacks().

See also Notes:
  • The allocation of space should be done in the way that following read and write operations will succeed within the specified resource size.

SpCallbackStorageWrite


Return to header index

_10
typedef int(* SpCallbackStorageWrite) (const char *storage_key, uint32_t offset, const void *data, uint32_t data_size, void *context)

Callback for writing the data into storage. Before writing to the storage eSDK does one of two things: call alloc to reserve space for future write or call read to get the data. After that eSDK writes the data into storage. Once write is fully complete eSDK calls close callback.

To register this callback, use the function SpRegisterStorageCallbacks().

See also Notes:
  • The application should not block or call other API functions in the callback. Offset field must always be respected on write operation. Application should consume whole data in the call.

SpCallbackStorageRead


Return to header index

_10
typedef int(* SpCallbackStorageRead) (const char *storage_key, uint32_t offset, void *data, uint32_t data_size, void *context)

Callback for reading the data. Once eSDK reads all required data, the close callback is called to notify the user that the data handle referenced by storage_key can be closed.

To register this callback, use the function SpRegisterStorageCallbacks().

See also Notes:
  • The application should not block or call other API functions in the callback. If no storage read is possible, just return 0.

SpCallbackStorageClose


Return to header index

_10
typedef void(* SpCallbackStorageClose) (const char *storage_key, void *context)

Callback to inform the user that the data handle referenced by storage_key can be closed.

To register this callback, use the function SpRegisterStorageCallbacks().

Notes:
  • The application should not block or call other API functions in the callback. This callback would be called for any successful alloc. For any resource open caused by Read/Write API calls.

SpCallbackStorageDelete


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackStorageDelete) (const char *storage_key, void *context)

Callback to inform the user that data referenced by storage_key should be deleted from storage.

To register this callback, use the function SpRegisterStorageCallbacks().

Notes:
  • The application should not block or call other API functions in the callback.
  • If the deletion operation is expected to take some time the application shall return kSpAPITryAgain for the duration of the operation and kSpAPINoError once it has been completed. It is important to not block execution of eSDK for prolonged periods (ideally less than 10ms). This callback can be called for literally any storage_key.

SpCallbackThrottleRequest


Return to header index

_10
typedef int(* SpCallbackThrottleRequest) (const char *storage_key, void *context)

eSDK calls this callback to figure out if it needs to limit write access to the storage.

Notes:
  • The application should not block or call other API functions in the callback.

SpRegisterStorageCallbacks


Return to header index

_10
SpError SpRegisterStorageCallbacks(struct SpDiskStorageCallbacks *cb, void *context)

Register storage callbacks.

Tls



_10
#include "spotify_embedded_tls.h"

Data Structures


Return to header index
SpTLSCallbacksCallbacks to be registered with SpRegisterTLSCallbacks()

Typedefs


Return to header index
SpCallbackTLSInitThis callback is invoked by eSDK to let the TLS library integration perform any one-time initialization.
SpCallbackTLSDeinitThis callback is invoked by eSDK to let the TLS library integration perform deallocation of resources during teardown.
SpCallbackTLSCreateThis callback is invoked once in the beginning of every TLS connection.
SpCallbackTLSHandshakeThis callback is invoked by eSDK to perform the TLS handshake.
SpCallbackTLSReadThis callback is invoked by eSDK to read data on a TLS connection.
SpCallbackTLSWriteThis callback is invoked by eSDK to write data on a TLS connection.
SpCallbackTLSCloseThis callback should clean up any resources allocated in the connect callback.
SpCallbackTLSGetErrorCallback invoked to get an error message for the last error.

Functions


Return to header index
SpRegisterTLSCallbacksRegister TLS-related callbacks.
SpTLSAddCARootCertAdd root certificate to the eSDK TLS stack.
SpTLSFreeCARootCertsRemove all certificates loaded on the TLS stack and free the memory used by them.

SpTLSCallbacks


Return to header index

_10
struct SpTLSCallbacks {
_10
SpCallbackTLSInit init;
_10
SpCallbackTLSDeinit deinit;
_10
SpCallbackTLSCreate create;
_10
SpCallbackTLSHandshake handshake;
_10
SpCallbackTLSRead read;
_10
SpCallbackTLSWrite write;
_10
SpCallbackTLSClose close;
_10
SpCallbackTLSGetError get_error;
_10
};

Callbacks to be registered with SpRegisterTLSCallbacks()

None of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackTLSInit initCallback that performs one-time initialization.
SpCallbackTLSDeinit deinitCallback that performs release of resources allocated during init.
SpCallbackTLSCreate createCallback invoked once per connection to initialize TLS context.
SpCallbackTLSHandshake handshakeCallback invoked repeatedly to perform the TLS handshake.
SpCallbackTLSRead readCallback for reading from the TLS data stream.
SpCallbackTLSWrite writeCallback for writing to the TLS data stream.
SpCallbackTLSClose closeCallback invoked to cleanup any TLS context before closing the socket.
SpCallbackTLSGetError get_errorCallback invoked to get an error message for the last error.

SpCallbackTLSInit


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackTLSInit) (void *context)

This callback is invoked by eSDK to let the TLS library integration perform any one-time initialization.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackTLSDeinit


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackTLSDeinit) (void *context)

This callback is invoked by eSDK to let the TLS library integration perform deallocation of resources during teardown.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackTLSCreate


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackTLSCreate) (struct SpSocketHandle *socket, const char *hostname, void *context)

This callback is invoked once in the beginning of every TLS connection.

The callback receives a socket via the pointer to SpSocketHandle that is already connected to the remote peer. This callback should typically allocate and set up all TLS related resources. The tls field of the SpSocketHandle should be used to store any connection specific state that is needed.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackTLSHandshake


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackTLSHandshake) (struct SpSocketHandle *socket, void *context)

This callback is invoked by eSDK to perform the TLS handshake.

The callback is invoked repeatedly to perform the handshake. This callback is invoked repeatedly as long as it returns kSpAPITryAgain. The peer verification is mandatory and the implementation of this callback must validate the peer certificate against a list of trusted CA certificates. Should return kSpAPIGenericError if the handshake failed. Any specific information about the reason for the failure will be returned in the SpCallbackTLSGetError() call.

Notes:
  • The application must not block or call other API functions in the callback.

SpCallbackTLSRead


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackTLSRead) (struct SpSocketHandle *socket, void *buf, size_t len, size_t *actual, void *context)

This callback is invoked by eSDK to read data on a TLS connection.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackTLSWrite


Return to header index

_10
typedef enum SpAPIReturnCode(* SpCallbackTLSWrite) (struct SpSocketHandle *socket, const void *buf, size_t len, size_t *actual, void *context)

This callback is invoked by eSDK to write data on a TLS connection.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackTLSClose


Return to header index

_10
typedef void(* SpCallbackTLSClose) (struct SpSocketHandle *socket, void *context)

This callback should clean up any resources allocated in the connect callback.

Notes:
  • The application should not block or call other API functions in the callback.

SpCallbackTLSGetError


Return to header index

_10
typedef int(* SpCallbackTLSGetError) (struct SpSocketHandle *socket, char *buf, size_t len, void *context)

Callback invoked to get an error message for the last error.

The implementation of this callback should put an error message in the form of a zero-terminated string in the buffer pointed to by buf. This error message should describe the latest error returned by any of the other callback functions.

Notes:
  • The application should not block or call other API functions in the callback.

SpRegisterTLSCallbacks


Return to header index

_10
SpError SpRegisterTLSCallbacks(struct SpTLSCallbacks *callbacks, void *context)

Register TLS-related callbacks.

Notes:
  • A call to this function has to be performed before SpInit() is called. Calling this function when eSDK is initialized will fail with kSpErrorAlreadyInitialized. The function will return kSpErrorUnsupported in the eSDK configurations with built-in TLS.

SpTLSAddCARootCert


Return to header index

_10
SpError SpTLSAddCARootCert(const uint8_t *certificate, size_t length, int *underlying_error)



This function is deprecated and should not be used. See alternatives:

Add root certificate to the eSDK TLS stack.

eSDK uses TLS secured HTTPS connections to download media files from CDN (Content Delivery Network) servers. All CDN servers are using certificates from common Certificate Authorities (CA). eSDK cannot read Certificate Authority (CA) root certificates from the operating system. The purpose of this function is to provide eSDK the CA root certificates which eSDK needs. As an example, integration can use the CA certificate bundle from Mozilla: https://curl.se/docs/caextract.html This API is cumulative and can be called several times until the integration has loaded all the certificates. This API allocates and owns the memory to store the certificates. The integration can reuse the memory used to pass the certificates (first parameter)

Notes:
  • If the buffer is a PEM-format certificate, it must be NULL-terminated.
  • If the buffer is a PEM-format certificate, this length must include the NULL termination.
  • Calls to this function have to be performed before SpInit() is called or after SpFree().

SpTLSFreeCARootCerts


Return to header index

_10
SpError SpTLSFreeCARootCerts(void)



This function is deprecated and should not be used. See alternatives:

Remove all certificates loaded on the TLS stack and free the memory used by them.

This API must be called before calling SpInit() or after SpFree().

Token



_10
#include "spotify_embedded_token.h"

Data Structures


Return to header index
SpTokenCallbacksCallbacks to be registered with SpRegisterTokenCallbacks()

Typedefs


Return to header index
SpCallbackConnectionReceiveAccessTokenCallback to deliver the access token requested by SpConnectionRequestAccessToken().
SpCallbackConnectionReceiveAuthCodeCallback to deliver the access token requested by SpConnectionRequestAuthCode().

Functions


Return to header index
SpRegisterTokenCallbacksRegister token callbacks.
SpConnectionRequestAccessTokenRequest an access token for the logged in user.
SpConnectionRequestAuthCodeRequest an authorization code for the logged in user.

SpTokenCallbacks


Return to header index

_10
struct SpTokenCallbacks {
_10
SpCallbackConnectionReceiveAccessToken on_access_token;
_10
SpCallbackConnectionReceiveAuthCode on_auth_code;
_10
};

Callbacks to be registered with SpRegisterTokenCallbacks()

Any of the pointers may be NULL. See the documentation of the callback typedefs for information about the individual callbacks.

SpCallbackConnectionReceiveAccessToken on_access_tokenAccess token event callbacks.
SpCallbackConnectionReceiveAuthCode on_auth_codeAuthorization code event callbacks.

SpCallbackConnectionReceiveAccessToken


Return to header index

_10
typedef void(* SpCallbackConnectionReceiveAccessToken) (const char *token_json, int error, void *context)

Callback to deliver the access token requested by SpConnectionRequestAccessToken().

Notes:
  • The JSON object looks as following: "accessToken":"tokendata", "expiresIn":expiryinseconds,//typically3600 "tokenType":"tokentype"//typically"Bearer"

SpCallbackConnectionReceiveAuthCode


Return to header index

_10
typedef void(* SpCallbackConnectionReceiveAuthCode) (const char *token_json, int error, void *context)

Callback to deliver the access token requested by SpConnectionRequestAuthCode().

Notes:
  • The JSON object looks as following: "code":"tokendata", "redirectUri":"someUri"

SpRegisterTokenCallbacks


Return to header index

_10
SpError SpRegisterTokenCallbacks(struct SpTokenCallbacks *cb, void *context)

Register token callbacks.

SpConnectionRequestAccessToken


Return to header index

_10
SpError SpConnectionRequestAccessToken(const char *scope)

Request an access token for the logged in user.

scope A comma-separated list of scopes for the resulting access token. See https://developer.spotify.com/documentation/web-api/concepts/scopes/

SpConnectionRequestAuthCode


Return to header index

_10
SpError SpConnectionRequestAuthCode(const char *scope)

Request an authorization code for the logged in user.

Notes:
  • The string scope must not be longer than 425 characters.