那么爱你不能拥有你- 林小棠
本帖最后由 亚伦影音工作室 于 2026-8-17 22:09 编辑 <br /><br /><style >#papa {margin: 10px -420px;
width: 1468px;
height: 740px;
background:#000000 url('https://pic1.imgdb.cn/i/7NPy3POmEzF6MZFLOF9AnA.gif')no-repeat center / cover;
box-shadow: 0px 0px 0px 2px #cccccc, 0px 0px 0px 8px #880000;
position: relative;overflow: hidden;
z-index: 12345;
}
#vid1 {z-index:1;
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0;
object-fit: cover;
}
#vid2 {z-index:2;
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0%;
object-fit: cover;
}
#boxa {width: 100%;position: absolute;top: -30px;left: 0%;z-index: 3;
height: 100%;-webkit-mask: url(https://pic1.imgdb.cn/i/0347Idy38SXalwDqQlOS2r.png)no-repeat center/60% 80%;}
#lrc {
--state: paused;
--motion: cover2;0
--tt: 2s;
--bg: linear-gradient(0deg, #ff0000, #ff0000, #ff0000);
position: absolute;z-index: 26;
left: 52%;
transform: translate(-50%);
top: 40px;
font:normal 3em 华文新魏;
font-weight:400;
color: #000080;
white-space: pre;
-webkit-background-clip: text;
filter:drop-shadow(#FFFFFF 1px 0 0)drop-shadow(#FFFFFF 0 1px 0)drop-shadow(#FFFFFF -1px 0 0) drop-shadow(#FFFFFF 0 -1px0);
}
#lrc::before {
position: absolute;
content: attr(data-lrc);
width: 20%;
height: 100%;
color: transparent;
overflow: hidden;
white-space: pre;
background: var(--bg);
-webkit-background-clip: text;
animation: var(--motion) var(--tt) linear forwards;
animation-play-state: var(--state);
}
@keyframes cover1{0% { width: 0%;}100% { width: 100%;}}
@keyframes cover2 { 0% { width: 0%;}100% { width: 100%;}}
</style >
<div id="papa">
<video id="vid1" src="https://img-baofun.zhhainiao.com/pcwallpaper_ugc/preview/b2b2d7852642be6394f57c8cab702bb0_preview.mp4" autoplay loop muted></video>
<div id="boxa"><video id="vid2" src="https://img-baofun.zhhainiao.com/pcwallpaper_ugc/preview/4ecf08a1fe1061aabd312bf498762e18_preview.mp4" autoplay loop muted></video></div>
<div id="lrc" data-lrc="那么爱你不能拥有你- 林小棠"title="歌词显示">那么爱你不能拥有你- 林小棠</div>
<audio id="aud" src="http://music.163.com/song/media/outer/url?id=3376167304.mp3" autoplay loop></audio>
</div>
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `缘分就像一场无声的雨
淋湿了我也淋湿了你
明明心动却不敢靠近
再多深情也无能为力
那么爱你却不能拥有你
情深缘浅只剩一声叹息
一场相遇换一生惦记
你住在我每次的梦里
那么爱你却只能放弃你
满心温柔都败给了天意
你是风景只剩空回忆
是我一生放不下的秘密
多少牵挂都埋进风里
多少眼泪都流进心底
错的时间遇见对的你
注定是一场心酸结局
那么爱你却不能拥有你
情深缘浅只剩一声叹息
一场相遇换一生惦记
你住在我每次的梦里
那么爱你却只能放弃你
满心温柔都败给了天意
你是风景只剩空回忆
是我一生放不下的秘密`;
/*变量 :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'),box.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),box.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());/*监听查询事件*/
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();
</script>
<script>
papa.onclick =function() { aud.paused ? ( aud.play(),vid1.play(),vid2.play()):(aud.pause(),vid1.pause(),vid2.pause())};
</script>
亚纶没有加播放器,直接用了背景点击。。。。 还是建议加个播放器上去 视频找的特别漂亮。效果很惊艳!{:4_199:} 视频找的特别漂亮。效果很惊艳!{:4_199:} 视频找的特别漂亮。效果很惊艳!{:4_199:} 复读机了,感觉卡,可能我的网速问题 清新靓丽,好听好看,谢谢亚伦老师精彩示范{:4_190:}
页:
[1]