谁能逃过世间因果(DJ 默涵版)-雨中百合
<style>#papa{ margin: 10px -150px;width: 1164px;box-shadow: 0px 0px 0px 2px #cccccc, 0px 0px 0px 6px #880000; overflow: hidden;height: 640px;background:#000000;border: 1px solid;display: grid;position: relative;z-index: 12345; --state: running;}
#mplayer {position:absolute; width: 250px; height: 55px;left: 8%; z-index: 120;top:65%;z-index: 1650;animation: rott 3s linear infinite;}
@keyframes rot{0% {opacity: 1;transform: scale(1);}100% {opacity: 1;transform:scale(1);filter:hue-rotate(360deg)contrast(100%)brightness(250%);}}
#an{position: absolute;
top:0%; left:0%;
width: 100%;
height:100%; z-index: 120;
}
@keyframes rott{0% {opacity: 1;filter:hue-rotate(360deg)contrast(100%)brightness(100%);}}
#pp { position: absolute; top: 75%;width: 100%; left:5px; z-index: 4;animation: rott 6s linear infinite;}
#lrc {
--state: paused;
--motion: cover2;
--tt: 2s;
--bg: linear-gradient(0deg, #ff0000, #ff0000, #ff0000);
position: absolute;z-index: 6;
left: 52%;
transform: translate(-50%);
top: 81%;
font:normal 3em 华文新魏;
font-weight:200;
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%;transform:rotateY(0deg)scale(1)}100% { width: 100%;transform:rotateY(0deg)scale(1);filter:hue-rotate(360deg)}}
@keyframes cover2 { 0% { width: 0%;transform:rotateY(0deg)scale(1)}100% { width: 100%;transform:rotateY(0deg)scale(1);filter:hue-rotate(360deg)}}
.photo {width: 100%;
height: 100%;
position: absolute;z-index: 4;
top:0px; left:0px;
opacity: 0;
animation: round 30s linear infinite;}
@keyframes round{
0% {
opacity: 1;transform:translate(0%,0%)scale(4);
}
10% {
opacity: 1;transform:translate(0%,0%)scale(1);
}
22% {
opacity: 1;transform:translate(0%,0%)scale(1);
}
25% {
opacity: 0;transform:translate(0%,0%)scale(1);}
}
.photo:nth-child(1) {animation-delay: 24s;background: url('https://pic.imgdb.cn/item/64e9ee70661c6c8e544cd94a.jpg') no-repeat center/cover;}
.photo:nth-child(2) {animation-delay: 18s;background: url('https://pic.imgdb.cn/item/64ec36d3661c6c8e54c4dcd6.jpg') no-repeat center/cover;}
.photo:nth-child(3) {animation-delay: 12s;background: url('https://pic.imgdb.cn/item/64ec353c661c6c8e54c461e0.jpg') no-repeat center/cover;}
.photo:nth-child(4) {animation-delay: 6s;background: url('https://pic.imgdb.cn/item/64ec3199661c6c8e54c39ffd.jpg') no-repeat center/cover;}
.photo:nth-child(5) {animation-delay: 0s;background: url('https://pic.imgdb.cn/item/64e9fa3f661c6c8e544f1b3a.jpg') no-repeat center/cover;}
.stop .photo:nth-child(1){animation-play-state: paused;}
.stop .photo:nth-child(2){animation-play-state: paused;}
.stop .photo:nth-child(3){animation-play-state: paused;}
.stop .photo:nth-child(4){animation-play-state: paused;}
.stop .photo:nth-child(5){animation-play-state: paused;}
#papa:hover #fullscreen { display:block ;}
#fullscreen { position: absolute; top:5%; left:83%;color:#ffffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2.2em华文新魏; opacity: 1; cursor: pointer; z-index: 1660}
</style>
<div id="papa">
<div id="Img" >
<div class="photo" ></div>
<div class="photo" ></div>
<div class="photo" ></div>
<div class="photo" ></div>
<div class="photo" ></div>
</div>
<canvas id="pp" title="亚伦影音" ></canvas>
<span id="fullscreen">全屏观赏</span>
<div id="lrc" data-lrc="谁能逃过世间因果(DJ 默涵版)">谁能逃过世间因果(DJ 默涵版)</div>
<div id="mplayer"><img height="100%" id="an" src="https://pic.imgdb.cn/item/64ee76b5661c6c8e546b61ba.gif" width="100%" /></div>
<audio id="aud" src="https://www.qqmc.com/mp3/music294926996.mp3" autoplay="" loop=""></audio>
</div>
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `谁能逃过世间因果(DJ 默涵版)-雨中百合
词:高国军
曲:春妹
OP: 亚伦影音工作室
青春年少已经渐渐干涸
多少梦想装满了苦涩
真心付出世人待我冷漠
心中的委屈已泪流成河
怦然心动变成惊鸿一瞥
多少思念装满了火热
擦肩而过剩下一片寂寞
心中的悔恨已无法选择
谁能逃得过世间的因果
把追名逐利彻底的淡薄
放下恩怨放下对错
谁不想逍遥快乐的生活
谁能逃得过世间的因果
把爱恨情仇彻底的看破
放下痴缠放下纠结
谁不想幸福快乐的度过
怦然心动变成惊鸿一瞥
多少思念装满了火热
擦肩而过剩下一片寂寞
心中的悔恨已无法选择
谁能逃得过世间的因果
把追名逐利彻底的淡薄
放下恩怨放下对错
谁不想逍遥快乐的生活
谁能逃得过世间的因果
把爱恨情仇彻底的看破
放下痴缠放下纠结
谁不想幸福快乐的度过
`;
/*变量 :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());/*监听查询事件*/
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();
/*函数 :频谱*/
(function() { ypData = ;
let total = 120,idx = 0;
let ctx =pp.getContext('2d');
let w =pp.width =1164, h = pp.height = 120;
let slice = w / total, vmax = Math.max.apply(null, ypData);
aud.loop = false;
ctx.strokeStyle = '#00ff00';
ctx.fillStyle = '#ffffff';
ctx.font = '14px sans-serif';
ctx.shadowOffsetX = ctx.shadowOffsetY = 1;
ctx.shadowBlur = 1;
ctx.shadowColor = '#000';
ctx.fillText('play', 80, 50);
aud.addEventListener('ended', () => { idx = 0; aud.play(); });
aud.addEventListener('timeupdate', () => {
draw();
idx ++;
if(idx > ypData.length - 1) idx = 0;
});
let draw = () => {
let ar = Array(total).fill('0').map( (v,k) => Math.random() * (ypData * h / vmax));
ctx.clearRect(0,0,w,h);
ctx.beginPath();
Array.from({length: total}).forEach((v,k) => ctx.lineTo(slice*k, h - ar));
ctx.stroke();
ctx.fillText(toMin(aud.currentTime) + ' / ' + toMin(aud.duration), 160, 20);
}
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 fs = true;
fullscreen.onclick = () => {
fs ? (fullscreen.innerText = '退出全屏',papa.requestFullscreen()) : (fullscreen.innerText = '全屏观赏', document.exitFullscreen());
fs = !fs;
};
</script>
<script>
if ('getContext' in document.createElement('canvas')) {
HTMLImageElement.prototype.play = function() {
if (this.storeCanvas) {
// 移除存储的canvas
this.storeCanvas.parentElement.removeChild(this.storeCanvas);
this.storeCanvas = null;
// 透明度还原
image.style.opacity = '';
}
if (this.storeUrl) {
this.src = this.storeUrl;
}
};
HTMLImageElement.prototype.stop = function() {
var canvas = document.createElement('canvas');
// 尺寸
var width = this.width, height = this.height;
if (width && height) {
// 存储之前的地址
if (!this.storeUrl) {
this.storeUrl = this.src;
}
// canvas大小
canvas.width = width;
canvas.height = height;
// 绘制图片帧(第一帧)
canvas.getContext('2d').drawImage(this, 0, 0, width, height);
// 重置当前图片
try {
this.src = canvas.toDataURL("image/gif");
} catch(e) {
// 跨域
this.removeAttribute('src');
// 载入canvas元素
canvas.style.position = 'absolute';
// 前面插入图片
this.parentElement.insertBefore(canvas, this);
// 隐藏原图
this.style.opacity = '0';
// 存储canvas
this.storeCanvas = canvas;
}
}
};
}
var imagee = document.getElementById("Img"),
image = document.getElementById("an"),
aud= document.getElementById('aud'),
button = document.getElementById("mplayer");
button.onclick = function() {
if (this.value == '停') {
image.play(); imagee.classList.remove('stop');aud.play();
this.value = '播';
} else {
image.stop(); imagee.classList.add('stop');aud.pause();
this.value = '停';
}
};
</script>
谢谢楼主分享,动感加特效非常漂亮{:5_150:} {:5_152:}{:5_152:}{:5_152:}
页:
[1]