西出阳关
本帖最后由 有声有色 于 2022-9-25 16:25 编辑 <br /><br /><style>#papa { left: -400px; width: 1400px; height: 800px; background: #ccc url('https://pic.imgdb.cn/item/632e90c116f2c2beb1abf044.gif') no-repeat center/cover; box-shadow: 3px 3px 20px #000; display: grid; place-items: center; position: relative; z-index: 1; }
#mplayer { position: absolute; top: 640px; width: 300px; height: 80px; user-select: none; display: grid; place-items: center; cursor: pointer; }
#mplayer:hover #btnwrap, #mplayer:hover #prog { transform: translateY(var(--yy)); }
#mplayer:hover #btnwrap { background: linear-gradient(to top right, red, green); border-radius: 50%; opacity: .75; }
#btnwrap, #prog { position: absolute; display: grid; place-items: center;transition: .5s; }
#btnwrap { --yy: -15px; width: 40px; height: 40px; transform: rotate(45deg); border: 1px solid tan; border-radius: 6px; opacity: .25; }
#btnplay { width: 20px; height: 20px; background: #eee; clip-path: polygon(0 0, 0% 100%, 100% 50%); }
#btnpause { width: 2px; height: 20px; border-style: solid; border-width: 0px 4px; border-color: transparent #eee; display: none; }
#prog { --yy: 20px; width: 300px; height: 16px; border-radius: 10px; background: linear-gradient(90deg, orange, red 100%, transparent 0); border: 1px solid gray; font: normal 14px / 16px sans-serif; color: #1551C8; opacity: .75; }
#lrc { position: absolute; top: 600px; font: bold 2em sans-serif; color: transparent; letter-spacing: 2px; background: linear-gradient(-90deg, darkred, pink) 100% 100% / 200% 200%; background-clip: text; -webkit-background-clip: text; }
#mpic { position: absolute; width: 100%; height: 100%; mix-blend-mode: multiply; }
@keyframes bgMove1 { from { background-position: 0 0; } to { background-position: -100% 0; } }
@keyframes bgMove2 { from { background-position: 0 0; } to { background-position: -100% 0; } }
</style>
<div id="papa">
<div id="lrc">花潮论坛lrc在线</div>
<div id="mplayer">
<div id="btnwrap"><span id="btnplay"></span><span id="btnpause"></span></div>
<div id="prog">00:00 | 00:00</div>
</div>
</div>
<script>
let lrcAr = [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
let mKey = 0, mSeek = false, mFlag = true;
let aud = new Audio();
aud.src = 'https://link.hhtjim.com/163/1830496538.mp3';
aud.autoplay = true;
aud.loop = true;
btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
prog.onclick = (e) => aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
aud.addEventListener('pause', () => mState());
aud.addEventListener('play', () => mState());
aud.addEventListener('seeked', () => calcKey());
aud.addEventListener('timeupdate', () => {
prog.style.background= 'linear-gradient(90deg, green, red ' + aud.currentTime / aud.duration * 100 + '%, snow 0)';
prog.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);
for(j=0; j<lrcAr.length; j++) {
if(aud.currentTime >= lrcAr) {
if(mKey === j) showLrc(lrcAr);
else continue;
}
}
});
let mState = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none', lrc.style.animationPlayState = 'paused') : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc.style.animationPlayState = 'running');
let showLrc = (time) => {
lrc.style.animation = (mFlag ? 'bgMove1 ' : 'bgMove2 ') + time + 's linear forwards';
lrc.innerHTML = lrcAr;
mKey += 1;
mFlag = !mFlag;
}
let calcKey = () => {
for(j = 0; j < lrcAr.length; j ++) {
if(aud.currentTime <= lrcAr) {
mKey = j - 1;
break;
}
}
if(mKey <0) mKey = 0;
let mtime = lrcAr - (aud.currentTime - lrcAr);
showLrc(mtime);
}
let toMin = (val)=> {
if (!val) return '00:00';
val = Math.floor(val);
let min = parseInt(val / 60), sec = parseFloat(val % 60);
if(min < 10) min = '0' + min;
if(sec < 10) sec = '0' + sec;
return min + ':' + sec;
}
</script> 这个做得完美,大气又漂亮。有声有色太赞了{:4_187:} 红影 发表于 2022-9-24 13:50
这个做得完美,大气又漂亮。有声有色太赞了
谢谢鼓励 问好有声有色~~做的非常漂亮{:4_199:} 代码中有个png图片没有出来,可以自己加这个图图进去 小辣椒 发表于 2022-9-24 16:32
代码中有个png图片没有出来,可以自己加这个图图进去
是吗,明天我试试,谢谢小辣椒老师 有声有色 发表于 2022-9-24 17:18
是吗,明天我试试,谢谢小辣椒老师
不客气{:4_187:} 西出阳关有故人,
四海一家人人亲。 有声有色 发表于 2022-9-24 14:32
谢谢鼓励
歌曲和背景图特别协调,非常漂亮的制作{:4_199:} 马黑黑 发表于 2022-9-24 18:40
西出阳关有故人,
四海一家人人亲。
是的 红影 发表于 2022-9-24 19:29
歌曲和背景图特别协调,非常漂亮的制作
看到这景色,就想起了当年上山下乡去的大西北 有声有色 发表于 2022-9-25 07:52
看到这景色,就想起了当年上山下乡去的大西北
看起来大西北的景色很不错啊,非常壮阔。您还参加过上山下乡啊,一份不错的人生经历{:4_187:} 红影 发表于 2022-9-25 10:08
看起来大西北的景色很不错啊,非常壮阔。您还参加过上山下乡啊,一份不错的人生经历
去内蒙整整9年半,青春都埋在打西北了 有声有色 发表于 2022-9-25 10:33
去内蒙整整9年半,青春都埋在打西北了
那么长时间啊,都成第二故乡了。 红影 发表于 2022-9-25 10:54
那么长时间啊,都成第二故乡了。
是的,那是响应老人家的号召啊,没办法 有声有色 发表于 2022-9-25 11:09
是的,那是响应老人家的号召啊,没办法
也算是一份契机,现在的人除了创业怎么可能跑去边疆,而那个时候那么多知识青年的付出,让边远地区的意识形态也有了提升,很大的手笔。 红影 发表于 2022-9-25 11:38
也算是一份契机,现在的人除了创业怎么可能跑去边疆,而那个时候那么多知识青年的付出,让边远地区的意识 ...
是的 有声有色 发表于 2022-9-25 12:23
是的
貌似回城挺不容易的,您能回沪,也是很幸运呢{:4_187:} 红影 发表于 2022-9-25 16:03
貌似回城挺不容易的,您能回沪,也是很幸运呢
后来国家有政策了,只要没结婚基本上都能回来, 有声有色 发表于 2022-9-25 16:06
后来国家有政策了,只要没结婚基本上都能回来,
哦哦,回来的好,还是自己的家乡更习惯。
页:
[1]
2