<html>
 <head> 
  <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
  <title>WebCat 音频播放器</title> 
  <style>
 .player {
  width: 300px;
  margin: 10px auto;
}
<p>.progress-bar {
width: 100%;
height: 10px;
background-color: #ccc;
}</p>
<p>#progress {
width: 0;
height: 100%;
background-color: #ff0000;
}
.playdio{
width:30px;
height:30px;
}
</style></p>
 </head> 
 <body> 
  <h1>WebCat 音频播放器</h1> 
  <div class="player"> 
   <audio id="audio-player" src="55168229191131-232174176229191181.mp3" ></audio> 
   <img class="playdio" id="ui" src="img/gdt_ic_express_play.png"/>
   <div class="progress-bar"> 
    <div id="progress"></div> 
   </div> 
  </div> 
  <script>
var audio = document.getElementById("ui")
const audioPlayer = document.getElementById('audio-player');
const progressBar = document.getElementById('progress');
<p>audioPlayer.addEventListener('timeupdate', function() {
const progress = (audioPlayer.currentTime / audioPlayer.duration) * 100;
progressBar.style.width = <code>${progress}%</code>;
});
audio.onclick=function (){
audio.play();
}
</script></p>
 </body>
</html>为什么无法播放内容:这段代码无法播放音频的原因是因为audio标签中的src属性值指向的音频文件路径不正确。请确保音频文件的路径是正确的,并且该文件存在于服务器上。如果文件路径正确,但仍然无法播放,可能是因为浏览器不支持该音频格式。你可以尝试使用其他格式的音频文件或者使用支持的浏览器来播放音频。
WebCat 音频播放器:无法播放音频的原因及解决方案

原文地址: https://www.cveoy.top/t/topic/pXV2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录