-
Notifications
You must be signed in to change notification settings - Fork 7
API documentation
LRain edited this page Jul 10, 2021
·
4 revisions
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 |
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 |
Property | Description |
---|---|
provider: string |
ID of the source provider |
name: string |
Song name |
artists: string |
Artists of the song, split with ,
|
album?: string |
Album of the song |
thumbnail?: string |
Thumbnail URL of the song |
thumbnailNoCrossOrigin?: string |
Should thumbnail be loaded without crossOrigin ? |
This type can be either FilePlaylist
, NeteasePlaylist
or QQPlaylist
Property | Description |
---|---|
type: string |
Type of playlist |
options: any |
Options for playlist |
This type is extended from BasePlaylist
Property | Description |
---|---|
type = "file"
|
None |
options: FilePlaylistItem[] |
Files in playlist |
This type is extended from BasePlaylist
Property | Description |
---|---|
type = "netease"
|
None |
options: string |
ID of playlist |
This type is extended from BasePlaylist
Property | Description |
---|---|
type = "qq"
|
None |
options: string |
ID of playlist |
Property | Description |
---|---|
name: string |
Song name |
artists: string[] |
Song artists |
url: string |
URL of the song file |
thumbnail?: string |
Thumbnail URL of the song |
album?: string |
Album name |
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 |