[交作业] 谢谢黑黑老师及红影朋友
本帖最后由 阙歌 于 2022-9-29 14:23 编辑 <br /><br /><style>#papa {
left: -420px;
width: 1600px;
height: 1000px;
display: grid;
place-items: center;
overflow: hidden;
position: relative;
z-index: 1;
background-image: url("https://img.wyc520.com.cn/data/attachment/forum/202209/29/135504enzce32687887w7b.jpg");
}
#mplayer {
position: absolute;
right: 647px;
bottom: 18px;
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, purple, orange); border-radius: 50%; opacity: .55; }
#btnwrap, #prog {
position: absolute;
display: grid;
place-items: center;
transition: .5s;
top: -25px;
}
#btnwrap { --yy: -15px; width: 40px; height: 40px; transform: rotate(45deg); border: 1px solid tan; border-radius: 6px; opacity: 0; }
#btnplay { width: 20px; height: 20px; transform: translateX(3px); 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, purple 100%, transparent 0); border: 1px solid teal; font: normal 14px / 16px sans-serif; color: #ccc; text-shadow: 0px 0px 0px #000; opacity: .25; }
#lrcwrap { position: absolute; top: 920px; font: bold 1.2em 'simsun',sans-serif; }
#lrc1, #lrc2 { width: 100%; height: 100%; color: snow; white-space: nowrap; }
#lrc2 { position: absolute; top: 0; left: 0; color: black; overflow: hidden; }
#mpic {position: absolute; transform: rotateY(180deg); left: 0; top: 0; width: 100px; offset-distance: 0; offset-path: path("M 0 0 Q 300 90, 512 100 T 1024 30"); animation: fly 18s linear infinite;}
@keyframes fly { to { offset-distance: 100%; } }
@keyframes mov1 { from { width: 0%;} to { width: 100%; } }
@keyframes mov2 { from { width: 0%;} to { width: 100%; } }
</style>
<div id="papa" data-lr="no">
<div id="lrcwrap">
<span id="lrc1">肩上的云</span>
<span id="lrc2">肩上的云</span>
</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 mKey = 0, mFlag = true, aud = new Audio();
let lrcAr = [
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
];
aud.src = 'https://pan.wyc520.net/H5/quege/jsdy02/10.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, orange, purple ' + 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', lrc2.style.animationPlayState = 'paused') : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc2.style.animationPlayState = 'running');
let showLrc = (time) => {
lrc2.style.animation = (mFlag ? 'mov1 ' : 'mov2 ') + time + 's linear forwards';
lrc1.innerHTML = lrc2.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;
if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;
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>
本帖最后由 阙歌 于 2022-9-29 14:25 编辑
谢谢! 我这是新手上路~~~~{:4_190:} 黑黑老师 请问,用什么软件编辑代码? 自己的翻唱啊,原来阙歌唱歌这么好的呢。制作很完美,点赞{:4_199:} 学习黑黑歌词同步的队伍又增加了,开心。不用谢我啊,我也是跟在黑黑后面学习的{:4_173:} 第一次做就很成功,这个歌词逐字同步做得很棒呢,阙歌学得很棒。{:4_204:} 红影 发表于 2022-9-29 14:38
第一次做就很成功,这个歌词逐字同步做得很棒呢,阙歌学得很棒。
多谢鼓励!黑黑老师分享的代码非常实用,不用找空间上传.css及.js 文件。 欣赏精美代码音画佳作! 喜欢就好! 阙歌 发表于 2022-9-29 14:52
多谢鼓励!黑黑老师分享的代码非常实用,不用找空间上传.css及.js 文件。
对呀,特别方便,而且可以有各种变化,特别好的代码呢。 阙歌 发表于 2022-9-29 14:31
黑黑老师 请问,用什么软件编辑代码?
我个人使用很多代码编辑器,最常用的,做小东西的话,Emeditor、MapEdit等等都可以,做大点的项目的话,一般会使用Visual Studio Code 或其他专业软件。
一般地,做帖子建议使用小巧免费的 MadEdit 编辑器,我有一份存档放在永硕网盘:
http://ys-j.ysepan.com/63457935/118978934/UUwSgOn752I581K68N346e/MadEdit-0.2.6-win32-bin.zip
如果以上链接不能直接下载,去到 http://gxblk.ysepan.com/ ,找常用软件目录 马黑黑 发表于 2022-9-29 18:24
我个人使用很多代码编辑器,最常用的,做小东西的话,Emeditor、MapEdit等等都可以,做大点的项目的话, ...
谢谢黑黑老师! 阙歌 发表于 2022-9-29 14:18
谢谢! 我这是新手上路~~~~
新手都制作的这么精彩{:4_178:} 精美的音画,深情的翻唱,作业完成的质量很高
页:
[1]