|
|

楼主 |
发表于 2022-2-12 18:23
|
显示全部楼层
只显示播放进度,代码量已经不少了,虽然外观看着这么单薄:
<style type="text/css">
#paDiv {
margin: auto;
width: 220px;
display: flex;
align-items: center;
border: 1px solid olive;
border-radius: 8px 0px 8px 0px;
background: rgba(0,0,0,.8);
box-shadow: 1px 1px 2px #000;
}
#jindu {
position: relative;
width: 200px;
height: 8px;
line-height: 8px;
font-size: 10px;
color: #eee;
text-align: center;
background: linear-gradient(90deg, olive, tan, gold) no-repeat;
background-size: 20px 0px;
}
#btn-ro {
width: 20px; height: 20px;
line-height: 20px; font-size: 12px;
background: linear-gradient(blue, silver, red);
outline:none;
color: white;
border-radius: 50%;
text-align: center;
cursor: pointer;
animation: rol linear 2s infinite;
}
#btn-ro:hover { opacity: 0.8; }
#btn-ro:active { opacity: 1; }
@keyframes rol { to { transform:rotate(360deg); } }
</style>
<div id="paDiv">
<div id="btn-ro">·</div>
<div id="jindu">
<div id="jd-go"></div>
</div>
</div>
<script language="javascript">
var btn = document.getElementById('btn-ro');
var jindu = document.getElementById('jindu');
var tips = document.getElementById('au-tips');
var aud = document.createElement('audio');
aud.src ="http://www.kumeiwp.com/sub/filestores/2022/02/06/d60dfa330d6f5f2da5e5027f19e33d73.mp3";
aud.addEventListener('ended', function() { btn.style.animationPlayState="paused"; }, true);
aud.addEventListener('timeupdate', tmMsg, true);
aud.play();
function tmMsg(){ //进度条
var jd = (100*aud.currentTime)/aud.duration;
jindu.innerHTML = Math.ceil(jd) + "%";
jindu.style.backgroundSize = jd+ "% 20px";
}
btn.onclick = function(){
aud.paused ? (aud.play(), btn.style.animationPlayState="running") : (aud.pause(), btn.style.animationPlayState="paused");
}
</script>
|
|