Skip to content
LRain edited this page May 22, 2021 · 4 revisions

APIs

You can find APIs in the following table inside window.PPlayer.

Property Description
initialize(id: string) or initialize(options: PenguinPlayerOptions) Initialize the player, can only be executed once
play(id?: number) Play, changes current song when id is specified
pause() Pause
next() Next song
previous() Previous song
setPlaymode(playmode: Playmodes) Set current playmode
addEventListener(name: string, listener: Function) Add a listener
removeEventListener(name: string, listener: Function) Remove a listener
volume: number Set or get current volume, between 0 - 1
currentTime: number Get or set current time
duration: number get only Get current song's duration
paused: boolean get only Get if the player is paused
song: Song get only Get current song
playlist: Song[] get only Get current playlist

Interfaces

PenguinPlayerOptions

Property Description Default Value
playlist: string | Playlist[] Player's playlist None
autoplay?: boolean Should play after playlist is loaded? true
startIndex?: number Which song should be played after playlist is loaded? Random
overrideVolume?: number Volume of the player 1 or user setting
overridePlaymode?: Playmodes Playmode of the player Playmodes.ListLoop or user setting

Song

Property Description
provider: string ID of the source provider
name: string Song name
artists: string Artists of the song, splitted with ,
album?: string Album of the song
thumbnail?: string Thumbnail URL of the song
thumbnailNoCrossOrigin?: string Should thumbnail be loaded without crossOrigin?

Enums

Playmodes

Entry Value Description
List 0 Play one by one, doesn't repeat the playlist
ListLoop 1 Play one by one, repeats the playlist
SingleLoop 2 Repeat current song
Random 3 Play randomly

Clone this wiki locally