加林森 发表于 2021-12-24 20:29
那就好那就好
{:4_170:}恩 必须小心
本帖最后由 加林森 于 2022-2-17 22:27 编辑 <br /><br />大猫咪 发表于 2021-12-24 20:31
恩 必须小心
你自己小心啊。{:4_170:}
<style>
#bigPa { position: relative; width: 1000px; left:-203px; height: 569px; background:#333 url('https://pic.imgdb.cn/item/620e33c12ab3f51d91487649.png') no-repeat center/cover; box-shadow: 0 0 0 2px #111;}
#gcDiv { width: 300px; float: right; }
#paDiv { position: relative; top: 10px; 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, green) no-repeat; background-size: 8px 0px; cursor: pointer; }
#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; }
#lrcDiv { position: relative; top: 20px; color: #A4D1D7; font-size: 1em; text-shadow: 1px 1px 2px #000; }
#btn-ro:hover { opacity: 0.8; }
#btn-ro:active { opacity: 1; }
@keyframes rol { to { transform:rotate(360deg); } }
</style>
<div id="bigPa">
<div id="gcDiv">
<!-- 播放器开始 -->
<div id="paDiv">
<div id="btn-ro">·</div><!-- 播放按钮 -->
<div id="jindu"><div id="jd-go"></div></div>
</div>
<!-- 播放器结束 -->
<div id="lrcDiv">歌词同步显示</div>
</div>
</div>
<script language="javascript">
var lrcAr=[
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
00:48.23〝,〝把整个冬天塞进我心里面〞],
,
,
,
,
,
,
,
,
,
,
,
,
,
];
var lrcDiv = document.getElementById('lrcDiv');
var btn = document.getElementById('btn-ro');
var jindu = document.getElementById('jindu');
var aud = document.createElement('audio');
// 音乐地址放在下行引号内
aud.src = "https:////music.163.com/outchain/player?type=2&id=25702009&auto=1&height=66";
aud.loop = true;
aud.autoplay = true;
aud.addEventListener('ended', function() { btn.style.animationPlayState="paused"; }, true);
aud.addEventListener('timeupdate', tmMsg, true);
function tmMsg(){ //进度条
let auT = Math.floor(aud.duration - aud.currentTime);
let auM = auT / 60;
let auMs = parseInt(auM);
if (auMs <10) auMs = "0" + auMs;
let auS = auT % 60;
let auSs = Math.round(auS);
if (auSs < 10) auSs = "0" + auSs;
jindu.innerHTML = "- " + auMs +":" + auSs;
let jd = (100*aud.currentTime)/aud.duration;
jindu.style.backgroundSize = jd+ "% 8px";
}
jindu.onclick = function(){ //进度控制
let w = offset(jindu,"left");
let x = (event.clientX - w) * aud.duration / jindu.clientWidth;
aud.currentTime = x;
}
function offset(obj,direction){//获取父级元素偏移总量
let offsetDir = "offset" + direction.toUpperCase()+direction.substring(1);
let realNum = obj;
let positionParent = obj.offsetParent;
while(positionParent != null){
realNum += positionParent;
positionParent = positionParent.offsetParent;
}
return realNum;
}
btn.onclick = function(){ // 暂停&播放
aud.paused ? (aud.play(), btn.style.animationPlayState="running") : (aud.pause(), btn.style.animationPlayState="paused");
}
//处理lrc歌词数组:时间转换成秒
for(j=0; j<lrcAr.length; j++){
lrcAr = toSec(lrcAr);
}
//lrc时间信息转为秒
function toSec(lrcTime) {
let tmpAr = lrcTime.split(':');
lrcTime = tmpAr * 60 + parseInt(tmpAr);
return lrcTime;
}
//同步显示歌词
aud.ontimeupdate = function() {
let tt = this.currentTime;
for(j=0; j<lrcAr.length; j++){
if(tt > lrcAr) lrcDiv.innerHTML = lrcAr;
}
}
</script>
加林森 发表于 2021-12-24 20:34
你自己小心啊。
嗯嗯 {:4_170:}
加林森 发表于 2021-12-24 17:35
先看着吧,不满意咱们又换。
要求不哈。{:4_334:}
大猫咪 发表于 2021-12-24 20:34
嗯嗯
哈哈哈哈。
樵歌 发表于 2021-12-24 20:43
要求不哈。
满意不满意啊?{:5_115:}
加林森 发表于 2021-12-24 20:52
满意不满意啊?
光俺们满意有用吗。{:4_375:}
樵歌 发表于 2021-12-24 21:37
光俺们满意有用吗。
那就是你的事情了,不管本队的事!你们自己考虑。。。。。。
加林森 发表于 2021-12-24 21:39
那就是你的事情了,不管本队的事!你们自己考虑。。。。。。
我考虑有用吗。{:4_189:}
樵歌 发表于 2021-12-25 13:33
我考虑有用吗。
当然有用了嘛
加林森 发表于 2021-12-25 16:45
当然有用了嘛
那好,俺们再打招。{:4_189:}
樵歌 发表于 2021-12-26 07:55
那好,俺们再打招。
这样就对了嘛
不错,大家谢谢加加
轩辕三光 发表于 2021-12-26 16:32
不错,大家谢谢加加
不客气的
加林森 发表于 2021-12-26 16:31
这样就对了嘛
想了关天,啥招都无用。{:4_189:}
樵歌 发表于 2021-12-27 08:07
想了关天,啥招都无用。
多想想嘛