// Type definitions for spotify-web-playback-sdk 0.1 (not on npm) // Project: https://beta.developer.spotify.com/documentation/web-playback-sdk/reference/ // Definitions by: Festify Dev Team // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Window { onSpotifyWebPlaybackSDKReady(): void; } declare namespace Spotify { const Player: typeof SpotifyPlayer; interface Album { uri: string; name: string; images: Image[]; } interface Artist { name: string; uri: string; } interface Error { message: string; } type ErrorTypes = 'account_error' | 'authentication_error' | 'initialization_error' | 'playback_error'; interface Image { url: string; } interface PlaybackContext { metadata: any; uri: string | null; } interface PlaybackDisallows { pausing: boolean; peeking_next: boolean; peeking_prev: boolean; resuming: boolean; seeking: boolean; skipping_next: boolean; skipping_prev: boolean; } interface PlaybackRestrictions { disallow_pausing_reasons: string[]; disallow_peeking_next_reasons: string[]; disallow_peeking_prev_reasons: string[]; disallow_resuming_reasons: string[]; disallow_seeking_reasons: string[]; disallow_skipping_next_reasons: string[]; disallow_skipping_prev_reasons: string[]; } interface PlaybackState { context: PlaybackContext; disallows: PlaybackDisallows; duration: number; paused: boolean; position: number; repeat_mode: RepeatMode; shuffle: boolean; restrictions: PlaybackRestrictions; track_window: PlaybackTrackWindow; } interface PlaybackTrackWindow { current_track: Track; previous_tracks: Track[]; next_tracks: Track[]; } interface PlayerInit { name: string; getOAuthToken(cb: (token: string) => void): void; volume?: number; } enum RepeatMode { NO_REPEAT = 0, ONCE_REPEAT = 1, FULL_REPEAT = 2, } class SpotifyPlayer { constructor(options: PlayerInit); connect(): Promise; disconnect(): void; getCurrentState(): Promise; getVolume(): Promise; nextTrack(): Promise; on(event: 'ready', cb: (pb: WebPlaybackInstance) => void): void; on(event: 'player_state_changed', cb: (pb: PlaybackState) => void): void; on(event: ErrorTypes, cb: (err: Error) => void): void; pause(): Promise; previousTrack(): Promise; resume(): Promise; seek(pos_ms: number): Promise; setVolume(volume: number): Promise; togglePlay(): Promise; } interface Track { uri: string; id: string | null; type: 'track' | 'episode' | 'ad'; media_type: 'audio' | 'video'; name: string; is_playable: boolean; album: Album; artists: Artist[]; } interface WebPlaybackInstance { device_id: string; } }