无编辑摘要 |
小无编辑摘要 |
||
| 第1行: | 第1行: | ||
<includeonly> | <includeonly> | ||
<link rel="stylesheet" href="https://cdn. | <!-- 引入国内CDN加速的APlayer资源 --> | ||
<script src="https://cdn. | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css"> | ||
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script> | |||
<script src="https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js"></script> | |||
<div | <style> | ||
/* 移动端适配 */ | |||
.aplayer { | |||
max-width: 100%; | |||
margin: 10px auto; | |||
font-family: -apple-system, "PingFang SC", "Microsoft YaHei"; | |||
} | |||
/* 小屏幕优化 */ | |||
@media screen and (max-width: 768px) { | |||
.aplayer-info { | |||
padding: 8px; | |||
} | |||
.aplayer-author { | |||
font-size: 12px; | |||
} | |||
.aplayer-controller .aplayer-bar { | |||
margin: 0 5px; | |||
} | |||
} | |||
</style> | |||
<div class="aplayer-box" | |||
data-title="{{{1|}}}" | |||
data-author="{{{2|}}}" | |||
data-pic="{{{3|}}}" | |||
data-url="{{{4|}}}" | |||
{{#forargs: song | | |||
| data-song-{{#var:key}} = "{{#var:value}}" | |||
}}> | |||
</div> | |||
<script> | <script> | ||
(function() { | (function() { | ||
// | // 收集歌曲数据 | ||
var songs = []; | |||
var box = document.querySelector('.aplayer-box'); | |||
// | // 处理多首歌曲参数 | ||
for(var i = 1; ; i++) { | |||
var prefix = "song" + i; | |||
var data = { | |||
title: box.dataset[prefix + 'title'], | |||
author: box.dataset[prefix + 'author'], | |||
url: box.dataset[prefix + 'url'], | |||
pic: box.dataset[prefix + 'pic'] | |||
}; | |||
if(!data.title) break; | |||
songs.push(data); | |||
} | } | ||
// | // 初始化播放器 | ||
var ap = new APlayer({ | |||
container: | container: box, | ||
audio: songs, | |||
audio: | fixed: false, | ||
listFolded: true, | |||
lrcType: 0, | lrcType: 0, | ||
theme: '#2980b9' | |||
}); | }); | ||
})(); | })(); | ||
</script> | </script> | ||
</includeonly> | </includeonly> | ||