DIYgod / APlayer

:lollipop: Wow, such a beautiful HTML5 music player
http://aplayer.js.org
MIT License
7.32k stars 1.03k forks source link

Is there an API to get information about the currently playing audio?如何获取当前正在播放的音频的信息? #778

Open felixwann opened 1 year ago

felixwann commented 1 year ago

English:

Song title, artist, lyrics, and other attribute values ​​in the audio array object? For example: Suppose there is a button on the page, when I click the button, I can get the current playing information through this API.

中文

如何获取当前正在播放的音频的信息?标题、艺人、歌词、以及audio数组对象里的其他信息? 例如:假设页面上有一个按钮,当我点击这个按钮时,获取当前播放的信息。

felixwann commented 1 year ago

自问自答,偶然间发现的

const ap = new APlayer(options);

ap.on('play', function (e) {
  console.log(e);
  console.log(ap.list.audios[ap.list.index]);
});