今天增加了背景音乐的功能,用的是APlayer.js,简单好用。我想用的歌曲找不到外链,摸索了下,也可以不用外链:
代码中的url也要改一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| const ap = new APlayer({ container: document.getElementById('aplayer'), fixed: true, autoplay: false, audio: [ { name: "玫瑰", artist: '张婧懿', url: '/music/玫瑰(Live).mp3', cover: 'https://p2.music.126.net/RJof0k6t2R-KHnmdUJBqjg==/109951163081250771.jpg?param=130y130', }, { name: "斑马,斑马", artist: '张婧懿', url: '/music/斑马斑马(Live).mp3', cover: 'https://p2.music.126.net/RJof0k6t2R-KHnmdUJBqjg==/109951163081250771.jpg?param=130y130', } ] });
|
运行结果: