Template:AudioPlayer: Difference between revisions
From Tuyin Archives
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{#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); | ||
if (!file || file === '{{{1}}}') { | if (!file || file === '{{{1}}}') { | ||
container.innerHTML = '<span style="color:red"> | 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'); | ||
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: | ||
} | } | ||
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> | ||
}} | }} | ||
Revision as of 20:09, 23 July 2025
