Template:AudioPlayer: Difference between revisions
From Tuyin Archives
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
<includeonly><html> | <includeonly><html> | ||
<script> | <script> | ||
function playAudio{{{1|replace:.,-}}}() { | |||
var audio = new Audio('{{{1}}}'); | |||
var | var button = document.getElementById('btn{{{1|replace:.,-}}}'); | ||
var | |||
if (button.innerHTML === '▶️') { | |||
audio.play(); | |||
button.innerHTML = '⏸️'; | |||
audio.addEventListener('ended', function() { | |||
button.innerHTML = '▶️'; | button.innerHTML = '▶️'; | ||
} | }); | ||
} | } else { | ||
audio.pause(); | |||
button.innerHTML = '▶️'; | |||
} | |||
} | |||
} | |||
} | |||
</script> | </script> | ||
<div style="display: inline-flex; align-items: center; gap: 12px;"> | <div style="display: inline-flex; align-items: center; gap: 12px;"> | ||
<div style="border: 1px solid #8B7355; padding: 8px; display: inline-block; border-radius: 4px; background-color: #F5F0E8; width: 200px;"> | <div style="border: 1px solid #8B7355; padding: 8px; display: inline-block; border-radius: 4px; background-color: #F5F0E8; width: 200px;"> | ||
<button id=" | <button id="btn{{{1|replace:.,-}}}" onclick="playAudio{{{1|replace:.,-}}}()" style="padding: 4px 8px; margin-right: 8px; font-size: 12px; border: 1px solid #8B7355; background: #D4C4A8; color: #5D4E37;">▶️</button> | ||
< | <span style="margin-left: 8px; color: #8B7355;">Audio Player</span> | ||
</div> | </div> | ||
<span style="color: #8B7355; font-style: italic;">{{{2|Audio File}}}</span> | <span style="color: #8B7355; font-style: italic;">{{{2|Audio File}}}</span> | ||
</div> | </div> | ||
</html></includeonly> | </html></includeonly> | ||
