Template:AudioPlayer: Difference between revisions

From Tuyin Archives
No edit summary
No edit summary
Line 1: Line 1:
<includeonly>
{{#tag:html|
{{#tag:html|
<div class="audioplayer" data-filename="{{{1}}}" data-label="{{{2|Audio File}}}"></div>
<div class="audioplayer" data-filename="{{{1}}}" data-label="{{{2|Audio File}}}"></div>
Line 9: Line 8:
      
      
     // Debug: show what we're getting
     // Debug: show what we're getting
     console.log('Filename:', file);
     console.log('Filename from template:', file);
    console.log('Label:', label);
      
      
     if (!file || file === '{{{1}}}') {
     if (!file || file === '{{{1}}}') {
       container.innerHTML = '<span style="color:red">No filename provided</span>';
       container.innerHTML = '<span style="color:red">Template parameter not working. File: ' + file + '</span>';
       return;
       return;
     }
     }
      
      
    // Rest of your original code...
     const oggUrl = 'https://tuyin.online/images/' + file;
     const oggUrl = 'https://tuyin.online/images/' + file;
     const mp3Url = oggUrl.replace('.ogg', '.mp3');
     const mp3Url = oggUrl.replace('.ogg', '.mp3');
   
    // Debug: show URLs
    console.log('OGG URL:', oggUrl);
    console.log('MP3 URL:', mp3Url);
   
     const audio = new Audio();
     const audio = new Audio();
     audio.preload = 'metadata';
     audio.preload = 'metadata';
   
     if (audio.canPlayType('audio/ogg')) {
     if (audio.canPlayType('audio/ogg')) {
       audio.src = oggUrl;
       audio.src = oggUrl;
Line 36: Line 29:
     }
     }
      
      
    // Rest of your code stays the same...
     const wrapper = document.createElement('div');
     const wrapper = document.createElement('div');
     wrapper.style.display = 'inline-flex';
     wrapper.style.display = 'inline-flex';
Line 102: Line 94:
</script>
</script>
}}
}}
</includeonly>

Revision as of 20:09, 23 July 2025