什么是APlayer
https://aplayer.js.org/#/zh-Hans/
安装
npm install aplayer –save
使用
找到node_modules -> aplayer(复制他的dist文件夹)
复制到F:\blog\themes\这里是你模板名称\source下(也就是你的主题配置文件下的source)
在dist文件夹下新建music.js
music.js 代码
const ap = new APlayer({
container: document.getElementById('aplayer'),
fixed: true,
autoplay: true,
lrcType: 3,
audio: [
{
name: "在水一方",
artist: '李健',
url: 'http://other.web.ri01.sycdn.kuwo.cn/resource/n2/31/23/2648161877.mp3',
cover: 'http://star.kuwo.cn/star/starheads/180/73/49/1131928591.jpg',
lrc: 'song-post/zaishuiyifang.lrc'
},
]
});
在你想播放的页面插入下面代码,xxx.ejs插入以下代码( < body>< /body>内)
<!-- 插入音乐 -->
<link rel="stylesheet" href="/dist/APlayer.min.css">
<div id="aplayer" ></div>
<script type="text/javascript" src="/dist/APlayer.min.js"></script>
<script type="text/javascript" src="/dist/music.js"></script>
然后即可播放音乐
转载于:https://blog.csdn.net/weixin_40842539/article/details/87655662