QMplayer
Install
$ npm i qm-player
Use
const QMplayer = const player =
Api
attribute
loop
A Boolean attribute: if specified, will automatically seek back to the start upon reaching the end of the audio.
muted
A Boolean attribute which indicates whether the audio will be initially silenced. Its default value is false.
currentTime
set or get currentTime
volume
set or get volume
duration
get audio duration
muted
set or get audio muted
index
get now song in playlist index
playlist
return song playlist
version
return QMplayer varsion
Methods
searchMusic(options,callback) 搜索歌曲
- options
Object
- callback
Function
test
player
result demo
playListAdd(musicId) 添加歌曲到播放列表
- musicId
String
musicId
in the method searchMusic
callback result data songid
or songmid
test
player //use songmid //orplayer //use songid // Check the playlistconsole
play(musicId?) 播放歌曲
- musicId
String
Optional
musicId
in the method searchMusic
callback result data songid
or songmid
test
player //use songmid // or player//use songid //or player // Select auto play in the playlist
playNext() 下一曲
test
player
playPrev() 上一曲
test
player
pause() 暂停
test
player
toggle() 切换播放状态
test
player
on(eventType,eventHandler) 添加事件绑定
-
eventType
String
Supported event types
error|play|pause
-
eventHandler
Function
eventHandler
test
playerplayerplayerplayer
off(eventType,eventHandler) 取消事件绑定
-
eventType
String
Supported event types
error|play|pause
-
eventHandler
Function
eventHandler
test
let { console } playerplayerplayerplayer