无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
< | <noinclude> | ||
<div id="aplayer-{{{1}}}" class="aplayer"></div> | {{Documentation}} | ||
</noinclude> | |||
<div id="aplayer-{{{1|default}}}" class="aplayer"></div> | |||
<script> | <script> | ||
(function() { | (function() { | ||
// 确保APlayer加载完成 | |||
function initAPlayer() { | |||
if (typeof APlayer === 'undefined') { | |||
setTimeout(initAPlayer, 100); | |||
return; | |||
} | |||
// 解析歌曲参数 | |||
var songs = []; | |||
{{#forargs: song | |||
| {{{songs|}}} | |||
| {{#if: {{#pos:{{#var:key}}|song}} | |||
} | | songs.push({ | ||
name: "{{#explode:{{#var:value}}|;|0}}", | |||
artist: "{{#explode:{{#var:value}}|;|1}}", | |||
} | url: "{{#explode:{{#var:value}}|;|2}}", | ||
cover: "{{#explode:{{#var:value}}|;|3|https://placehold.co/80x80?text=No+Cover}}" | |||
}); | |||
}} | |||
}} | |||
// 初始化播放器 | |||
new APlayer({ | |||
container: document.getElementById('aplayer-{{{1|default}}}'), | |||
audio: songs, | |||
lrcType: 0, | |||
fixed: false, | |||
mini: false, | |||
theme: '#2980b9' | |||
}); | |||
} | |||
// 等待DOM加载完成后执行 | |||
document.addEventListener('DOMContentLoaded', initAPlayer); | |||
})(); | })(); | ||
</script> | </script> | ||
2025年3月16日 (日) 06:05的版本
<script> (function() {
// 确保APlayer加载完成
function initAPlayer() {
if (typeof APlayer === 'undefined') {
setTimeout(initAPlayer, 100);
return;
}
// 解析歌曲参数
var songs = [];
{{#forargs: song
|
| {{#if: {{#pos:{{#var:key}}|song}}
| songs.push({
name: "{{#explode:{{#var:value}}|;|0}}",
artist: "{{#explode:{{#var:value}}|;|1}}",
url: "{{#explode:{{#var:value}}|;|2}}",
cover: "{{#explode:{{#var:value}}|;|3|https://placehold.co/80x80?text=No+Cover}}"
});
}}
}}
// 初始化播放器
new APlayer({
container: document.getElementById('aplayer-default'),
audio: songs,
lrcType: 0,
fixed: false,
mini: false,
theme: '#2980b9'
});
}
// 等待DOM加载完成后执行
document.addEventListener('DOMContentLoaded', initAPlayer);
})(); </script>