At the simplest level, the SDK provides a singleton music player with play, pause, skip, like, dislike, and volume controls. The player, upon initialization, retrieves a list of available stations from the Adaptr servers that contain songs the player can retrieve and play. At any given time, a single station is the active station from which songs are retrieved for playback. The player offers methods for retrieving the music available in each station (through pagination or search) so that individual tracks can be played back on demand and client side playlists can be created.
The player generates and caches a random unique client id that is stored and sent with all network requests to track playback history and enforce playback restrictions.
The player can be commanded to play and pause music playback. All calls to the player are asynchronous, so events are emitted that indicate when songs start, elapse, and complete playback. Once the music begins, there will always be a current song with associated metadata that can be displayed to the user. Calls to like and dislike inform the Adaptr servers how a user feels about the current song.
The player maintains a public state, which will be one of the following:
- uninitialized: the player hasn't been given a token/secret pair yet
- unavailable: music is not available to the user for some reason
- ready to play: the player is idle and can begin playback, but hasn't
- offline only: the player is idle and ready to play, but only offline stations will currently work.
- waiting for item: the player is waiting for Adaptr to give it a song to play
- stalled: the player is blocked and waiting for audio data for the current song (it is buffering)
- playing: the player is actively playing a song
- paused: the player has paused playback
- complete: the player has reached the end of music in the current station.