All I Ask of You
本帖最后由 绿叶清舟 于 2023-4-30 20:44 编辑 <br /><br /><style>#papa { --state: paused; --deg: 1turn;
margin: -80px 0 0 calc(50% - 633px);
width: 1100px;
height: 700px;
background: lightgreen url('https://pic2.imgdb.cn/item/644c57bc0d2dde5777f9365d.jpg') no-repeat center/cover;
box-shadow: 3px 3px 20px #000;
position: relative;
z-index: 1;
}
#mplayer {
position: absolute;
width: 130px;
height: 130px;
right: 130px;
top: 400px;
border-radius: 50%;
cursor: pointer;
opacity: 0.8;
animation: rot 8s linear infinite;
}
#lrc {
--state: paused;
--motion: cover2;
--tt: 2s;
--bg: linear-gradient(180deg, hsla(195, 83%, 71%, .45), hsla(195, 83%, 50%, .65));
position: absolute;
left: 50%;
transform: translate(-50%);
top: 615px;
font: bold 2em sans-serif;
color: snow;
white-space: pre;
-webkit-background-clip: text;
filter: drop-shadow(1px 1px 2px hsla(0, 0%, 0%, .95));
}
#lrc::before {
position: absolute;
content: attr(data-lrc);
width: 20%;
height: 100%;
color: transparent;
overflow: hidden;
white-space: pre;
background: var(--bg);
filter: inherit;
-webkit-background-clip: text;
animation: var(--motion) var(--tt) linear forwards;
animation-play-state: var(--state);
}
@keyframes root {from{ transform: rotateY(360deg); }to { transform: rotateY(-360deg); } }
@keyframes rot { to { transform: rotate(var(--deg)); } }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</style>
<div id="papa">
<div id="lrc" data-lrc="All I Ask of You">All I Ask of You</div>
<div id="mplayer"> <img id="mp" src="https://pic2.imgdb.cn/item/644c6a9a0d2dde57770a3191.png" alt="" /></div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=3406394.mp3" loop autoplay></audio>
</div>
<script>
(function() {
/*原始lrc歌词*/
let lrcStr = `
No more talk of darkness<BR>暗夜不再提起
Forget these wide-eyed fears<BR>驱散满眼恐惧
I m here有我
nothing can harm you -<BR>始终守护你
my words will warm and calm you<BR>耳畔是温暖细语
Let me be your freedom<BR>给你自由羽翼
let daylight dry -your tears<BR>阳光拭干泪啼
I m here<BR>有我
with you beside you<BR>和你在一起
to guard you守护你
and to guide you<BR>指引你
CHRISTINE
Say you love me<BR>说你爱我
every waking moment<BR>无论何时梦醒
turn my head<BR>爱情盛放
with talk of summertime<BR>如夏日旖旎
Say you need me with you now and always<BR>说你要我,一生永不分离
promise me that all<BR>告诉我
you say is true -<BR>眼神执着肯定
that s all I ask of you<BR>除此我别无所求
RAOUL
Let me be your shelter<BR>漫天风雪已起
let me be your light<BR>你在我怀中避
You re safe<BR>你很安全
No-one will find you<BR>没有人会找到你
your fears are far behind you<BR>恐惧远离
CHRISTINE
All I want is freedom<BR>所求是自由光明
a world with no more nigh<BR>t为何心中未已
and you always beside me<BR>只你,无尽地给予
to hold me and to hide me<BR>似让我沐浴甘霖
RAOUL
Then say you ll share with me one love one lifetime<BR>共享爱的甘醇,共享这生命
Iet me lead you<BR>让我领你
from your solitude<BR>走出孤与寂
Say you need me with you<BR>我会陪你
here beside you<BR>此生此情不渝
anywhere you go就算开际
let me go too -<BR>你我形影不离
Christine
that s all I ask of you<BR>你就是我唯一
CHRISTINE
Say you ll share with me one love one lifetime<BR>共享爱情,共享这生命
say the word<BR>只要你说
and I will follow you<BR>从今我将一直追随你
BOTH
Share each day with me each night each morning<BR>每个晨昏日夜都相依
CHRISTINE
Say you love me<BR>说你爱我
RAOUL
You know I do<BR>我真爱你
BOTH
Love me <BR>-爱我
that s all I ask of you<BR>除此我别无所求
(They kiss)
Love me -<BR>爱我
that s all I ask of you<BR>除此我别无所求
`;
/*变量 :mKey - 当前歌词索引;mFlag :调用关键帧动画索引;averAdd :平均值补偿*/
let mKey = 0, mFlag = true, averAdd = 0.3;
/*函数 :获取每句歌词用时,歌词用时若超过平均值则取平均值,最后一句歌词则取平均值*/
let lrcTime = (ar) => {
let tmpAr = [];
for(j = 0; j <ar.length - 1; j ++) {
if(j !== ar.length - 1) tmpAr = parseFloat((ar - ar).toFixed(1));
}
let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
tmpAr.push(aver);
tmpAr.forEach((item,key) => {
ar = item > aver ? aver : item;
});
return ar;
};
/*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
let getLrcAr = (text) => {
let lrcAr = [];
let calcRule = ;
for(x of text.split('\n')) {
let ar = [];
let re = /\d+[\.:]\d+([\.:]\d+)?/g;
let geci = x.replace(re,'');
if(geci) {
geci = geci.replace(/[\[\]\'\"\t,]s?/g,'');
let time = x.match(re);
if(time != null) {
for(y of time) {
let tmp = y.match(/\d+/g);
let sec = 0;
for(z in tmp) sec += tmp * calcRule;
ar = ;
lrcAr.push(ar);
}
}
}
}
lrcAr.sort((a,b)=> a - b);
return(lrcTime(lrcAr));
};
/*函数 :模拟显示同步歌词*/
let showLrc = (time) => {
let name = mFlag ? 'cover1' : 'cover2';
lrc.innerHTML = lrcAr;
lrc.dataset.lrc = lrcAr;
lrc.style.setProperty('--motion', name);
lrc.style.setProperty('--tt', time + 's');
lrc.style.setProperty('--state', 'running');
mKey += 1;
mFlag = !mFlag;
};
/*函数 :处理当前歌词索引 mKey*/
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 time = lrcAr - (aud.currentTime - lrcAr);
showLrc(time);
};
/*格式化时间信息*/
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;
}
/*函数 :关键帧动画状态切换*/
let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),mplayer.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),mplayer.style.animationPlayState = 'running');
/*监听播放进度*/
aud.addEventListener('timeupdate', () => {
for (j = 0; j < lrcAr.length; j++) {
if (aud.currentTime >= lrcAr) {
cKey = j;
if (mKey === j) showLrc(lrcAr);
else continue;
}
}
});
aud.addEventListener('pause', () => mState());/*监听暂停事件*/
aud.addEventListener('play', () => mState());/*监听播放事件*/
aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
mplayer.addEventListener('click', () => { aud.paused ? aud.play() : aud.pause(); });
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();
</script> 面具戴手上了{:4_170:} 面具是个好东东,戴上胆儿又肥又壮{:4_170:} 这个是歌剧么,好听。用面具做播放器按钮,清舟好构思{:4_199:} 清舟这个面具2窟窿,怕怕的{:4_198:} 画面与歌曲相得益彰{:4_199:} 马黑黑 发表于 2023-4-29 09:35
面具戴手上了
为啥加了换行,下面的中文字就和上面的不一致了 罗浮梦 发表于 2023-4-29 21:54
画面与歌曲相得益彰
谢谢罗浮梦,节日好 小辣椒 发表于 2023-4-29 21:23
清舟这个面具2窟窿,怕怕的
贴子发出来才想到,应该用个渐隐,效果会比现在这个好些{:4_189:} 红影 发表于 2023-4-29 18:05
这个是歌剧么,好听。用面具做播放器按钮,清舟好构思
是啊,歌剧魅影里的 醉美水芙蓉 发表于 2023-4-29 11:45
面具是播放器?
是啊,不知道咋玩了 樵歌 发表于 2023-4-29 10:51
面具是个好东东,戴上胆儿又肥又壮
樵歌想到啥了啊{:4_189:} 绿叶清舟 发表于 2023-4-30 11:11
贴子发出来才想到,应该用个渐隐,效果会比现在这个好些
是啊,加一点透明度,2窟窿线条不会这么明显 绿叶清舟 发表于 2023-4-30 11:10
为啥加了换行,下面的中文字就和上面的不一致了
它们本来就不一致:一个英文一个汉语 很好看,祝大家节日快乐! 小辣椒 发表于 2023-4-30 12:54
是啊,加一点透明度,2窟窿线条不会这么明显
加了一点,本来到.5的感觉整个一起透了 梦缘 发表于 2023-4-30 20:35
很好看,祝大家节日快乐!
谢谢梦缘,节日快乐 绿叶清舟 发表于 2023-4-30 11:13
樵歌想到啥了啊
俺想戴上面具好实現想之所想{:4_173:} 樵歌 发表于 2023-4-30 23:08
俺想戴上面具好实現想之所想
祝愿所想成真{:4_189:}
页:
[1]
2