Warning: is_readable(): open_basedir restriction in effect. File(/gitinfo/info.json) is not within the allowed path(s): (/www/wwwroot/wiki.guguwo.top/:/tmp/) in /www/wwwroot/wiki.guguwo.top/includes/utils/GitInfo.php on line 177
模板:APlayer:修订间差异 - 咕咕窝wiki

模板:APlayer:修订间差异

来自咕咕窝wiki
无编辑摘要
无编辑摘要
第1行: 第1行:
<includeonly>
<noinclude>
<div id="aplayer-{{{1}}}" class="aplayer"></div>
{{Documentation}}
</noinclude>
<div id="aplayer-{{{1|default}}}" class="aplayer"></div>
<script>
<script>
(function() {
(function() {
    var loadResources = function() {
  // 确保APlayer加载完成
        if(typeof APlayer === 'undefined') {
  function initAPlayer() {
            // 动态加载CSS
    if (typeof APlayer === 'undefined') {
            var css = document.createElement('link');
      setTimeout(initAPlayer, 100);
            css.href = 'https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css';
      return;
            css.rel = 'stylesheet';
    }
            document.head.appendChild(css);


            // 动态加载JS
    // 解析歌曲参数
            var js = document.createElement('script');
    var songs = [];
            js.src = 'https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js';
    {{#forargs: song
            js.onload = initializePlayer;
      | {{{songs|}}}
             document.body.appendChild(js);
      | {{#if: {{#pos:{{#var:key}}|song}}
         } else {
          | songs.push({
            initializePlayer();
              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}}"
             });
         }}
     }}


     var initializePlayer = function() {
     // 初始化播放器
        new APlayer({
    new APlayer({
            container: document.getElementById('aplayer-{{{1}}}'),
      container: document.getElementById('aplayer-{{{1|default}}}'),
            audio: [{
      audio: songs,
                name: '{{{2|未命名曲目}}}',
      lrcType: 0,
                artist: '{{{3|未知艺术家}}}',
      fixed: false,
                url: '{{{4}}}',
      mini: false,
                cover: '{{{5|https://example.com/default-cover.jpg}}}',
      theme: '#2980b9'
                lrc: '{{{6|}}}'
    });
            }]
  }
        });
    };


    // 延迟加载防止阻塞页面
  // 等待DOM加载完成后执行
    if(window.addEventListener) {
  document.addEventListener('DOMContentLoaded', initAPlayer);
        window.addEventListener('load', loadResources, false);
    } else if(window.attachEvent) {
        window.attachEvent('onload', loadResources);
    }
})();
})();
</script>
</script>
</includeonly>

2025年3月16日 (日) 06:05的版本

模板:Documentation

<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>