UNPKG

lunify.js

Version:

A basic api wrapper for the spotify api covering the oauth routes.

95 lines (94 loc) 2.92 kB
import { CurrentPlayback } from "./CurrentPlayback"; import type { Lunify } from "../.."; import { PlayerDeviceManager } from "../../managers/devices"; import type { PartialUser, User } from "../user"; export * from "./CurrentPlayback"; export * from "./Device"; export declare class Player { client: Lunify; user: User | PartialUser; devices: PlayerDeviceManager; constructor(client: Lunify, user: User | PartialUser); /** * Get current plackback (⚠️ This data is fetched from the api, not from a websocket, consider rate limits) * @example ```ts * const playing = player.now(); * console.log(playing) * ``` */ now(): Promise<CurrentPlayback | null>; /** * Start playing a track on users current device * @param {string | string[]} track - A spotify track id or a list of spotify track ids * @example ```ts * player.start('6IRdLKIyS4p7XNiP8r6rsx'); * ``` */ play(trackId: string | string[]): Promise<boolean>; /** * Resume playback on users current device with paused track * @example ```ts * player.resume(); * ``` * Use `.play(...)` to start playing a new track */ resume(): Promise<boolean>; /** * Stop playback on users current device * @example ```ts * player.stop(); * ``` */ stop(): Promise<boolean>; /** * Skip the current track and start playing the next one * @example ```ts * player.skip(); * ``` */ skip(): Promise<boolean>; /** * Start playing the track before the current one (starts playing previous track) * @example ```ts * player.rewind(); * ``` */ rewind(): Promise<boolean>; /** * Seek to any position in the current playback * @param {number} position - position in milliseconds (seconds x1000) * @example ```ts * player.seek(16 * 1000); // 16 seconds * ``` */ seekTo(position: number): Promise<boolean>; /** * Set the repeat mode for the current playback * @param {'track' | 'context' | false} mode - track, context, false * - track: repeat the current track * - context: repeat the current context * - false: turn repeat off * @example ```ts * player.repeat('track'); * player.repeat('context'); * player.repeat(false); * ``` */ repeat(mode: "track" | "context" | false): Promise<boolean>; /** * Set the volume for the current playback device * @param {number} percentage - volume in percent % * @example ```ts * player.volumeTo(69); // 69% * ``` */ volumeTo(percentage: number): Promise<boolean>; /** * Toggle shuffle on or off for playback * @param {number} state - volume in percent % * @example ```ts * player.shuffle(true); * ``` */ shuffle(state: boolean): Promise<boolean>; }