Options
All
  • Public
  • Public/Protected
  • All
Menu

Cordova Spotify Plugin

Index

Functions

getEventEmitter

  • getEventEmitter(): Promise<Emitter>
  • Obtains an event emitter that relays the events fired by the native SDKs.

    The emitter will be created once and then returned on subsequent invocations. The emitter implementation comes from eventemitter3.

    The emitted events are the following:

    • connectionmessage
    • loggedin
    • loggedout
    • loginfailed
    • playbackerror
    • playbackevent
    • temporaryerror

    In the case of loginfailed, playbackevent and playbackerror, the event contains a payload that describes what happened exactly. The payload is simply the name of the discriminant of the enum in the native SDK without the prefix (usually kSp or kSpError). See the offical documentation here and here for all variants.

    async

    Returns Promise<Emitter>

    A promise that resolves to the emitter.

getPosition

  • getPosition(): Promise<number>
  • Obtains the playback position in milliseconds.

    If no track is currently loaded / playing, the function returns 0.

    async

    Returns Promise<number>

    A promise with the playback position.

pause

  • pause(): Promise<void>
  • Pauses playback.

    If no track is currently loaded / playing, this function does nothing.

    async

    Returns Promise<void>

    A promise that resolves when the playback has been paused.

play

  • play(trackUri: string, auth: AuthorizationData, positionMs?: number): Promise<void>
  • Plays a track by its URI.

    When positionMs is < 0, this function immediately throws an error instead of returning a rejected promise.

    auth may change freely during runtime. The plugin will handle the required login / logout processes automatically when a new track is played.

    async

    Parameters

    • trackUri: string

      The URI of the track to play.

    • auth: AuthorizationData

      Valid authorization data.

    • Optional positionMs: number

      The position (in millseconds) to start playing from. Must be >= 0.

    Returns Promise<void>

    A promise that resolves when the track starts playing.

resume

  • resume(): Promise<void>
  • Resumes playback.

    If no track is currently loaded / playing, this function returns a rejected Promise with an error of type not_playing.

    async

    Returns Promise<void>

    A promise that resolves when the playback has been resumed.

seekTo

  • seekTo(positionMs: number): Promise<void>
  • Seeks to the given position in the current track.

    If no track is currently loaded / playing, this function returns a rejected Promise with an error of type not_playing.

    When positionMs is < 0, this function immediately throws an error instead of returning a rejected promise.

    async

    Parameters

    • positionMs: number

      The position (in millseconds) to seek to. Must be >= 0.

    Returns Promise<void>

    A promise that resolves when the seek has been done.

Generated using TypeDoc