架子鼓控件 问一问时光 - 魏佳艺
<style>#papa {
margin: 10px -300px;
width: 1164px;
height: 620px;
background: url('https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/168ec7c864954497490b205ff0a2d79c.jpg') center/cover no-repeat;
box-shadow:0px 0px 0px 6px #880000;
position: relative;
z-index: 1;
--state: paused;overflow:hidden;
}
.photo {width: 70%; height: 70%;box-shadow:0px 0px 0px 4px #880000;
position: absolute;z-index: 4;
top:20px; left:260px;filter:contrast(120%)brightness(100%);
opacity: 0;
animation-name: round ;animation-duration: 32s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@keyframes round {0% {
opacity: 0;
-webkit-transform:translate(0%,0%)scale(1);}
8% {
opacity: 1;
-webkit-transform:translate(0%,0%)scale(1);}
10% {
opacity: 1;
-webkit-transform:translate(0%,0%)scale(1);}
18% {
opacity: 0;
-webkit-transform:translate(0%,0%)scale(1);}
}
.photo:nth-child(1) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/f8b2a6523a38c3c6c61be0ac6501d6e9.jpg)0 0/100% 100%;
animation-delay: 28s;
}
.photo:nth-child(2) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/29c50e716edbe7f5bd4004c1fae3a5cc.jpg)0 0/100% 100%;
animation-delay: 24s;
}
.photo:nth-child(3) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/c8eff17a7a0d1132a001fc899d9d51e4.jpg)0 0/100% 100%;
animation-delay: 20s;
}
.photo:nth-child(4) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/3d56f2dfc5ee58313cd2c9113ae2beed.jpeg)0 0/100% 100%;
animation-delay: 16s;
}
.photo:nth-child(5) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/a8fa482d66a757a54c2abd72ef68243a.jpg)0 0/100% 100%;
animation-delay: 12s;
}
.photo:nth-child(6) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/17f43572bffffec2c3a21152d05598bc.jpg)0 0/100% 100%;
animation-delay: 8s;
}
.photo:nth-child(7) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/148ac3256a463f25a0bc67fc74722d9f.jpg)0 0/100% 100%;
animation-delay: 4s;
}
.photo:nth-child(8) {background:url(https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/9ffc373a1dadbf420296df3f08fad75f.jpg)0 0/100% 100%;
animation-delay: 0s;
}
.st img:nth-child(1) {
animation-play-state: paused;
}
.st img:nth-child(2){
animation-play-state: paused;
}
.stimg:nth-child(3){
animation-play-state: paused;
}
.st img:nth-child(4){
animation-play-state: paused;
}
.st img:nth-child(5){
animation-play-state: paused;
}
.st img:nth-child(6){
animation-play-state: paused;
}
.st img:nth-child(7) {
animation-play-state: paused;
}
.st img:nth-child(8) {
animation-play-state: paused;
}
#mplayer {position: absolute;
top:60%; left:0%;z-index: 20;
width: 220px;filter:hue-rotate(20deg);
height:210px;
}
#vid { display: none; }
#canv {width: 100%;height: 100%;
position: absolute;
display: block;
left:0%;mix-blend-mode: soft-light;
top: 0%;z-index: 4;
border-radius: 0%;
opacity: 1;
}
@keyframes flash {
to { box-shadow: 0 0 30px white; }
}
#fg{width: 100%;height: 100%;top:0px; left:0px;position: absolute; z-index: 1;animation: slider 3s linear infinite ;opacity: 0;}
@keyframes slider {0% { background:#000080 ; } 50% {background:#000000;} 100%{} }
</style>
<div id="papa">
<div id="testImg"><img class='photo '><img class='photo ' ><img class='photo '><imgclass='photo '><img class='photo ' ><img class='photo '><imgclass='photo '><imgclass='photo '></div>
<div id="fg"></div>
<canvas id="canv"></canvas>
<div id="mplayer"><img id="an" src="https://www.yiyuen.com/e/file/view/589065" width="100%" height="100%">
</div>
<div data-lrc="亚伦影音工作室" id="lrc">亚伦影音工作室</div>
</div>
<audio id="aud" src="https://www.qqmc.com/mp3/music277195145.mp3" autoplay loop></audio>
<video id="vid" src="https://img-baofun.zhhainiao.com/pcwallpaper_ugc/preview/2c4ee70c827cbcefcb69ac0ee18af09e_preview.mp4" loop autoplay muted></video>
<script>
let ctx = canv.getContext('2d');
let ww = canv.width = 1000, hh = canv.height =250;
let loop = () => {ctx.drawImage(vid, 0, 0, ww, hh);if(!vid.paused) {requestAnimationFrame(loop);return;}}
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 ? (papa.style.setProperty('--state', 'paused'),vid.pause()) : (papa.style.setProperty('--state', 'running'),vid.play());
vid.playbackRate = 0.5;
vid.addEventListener('play', loop, false);
aud.addEventListener('play', () => mState());
aud.addEventListener('pause', () => mState());
aud.addEventListener('timeupdate', () => mplayer.dataset.tt = '.\n\n' + toMin(aud.duration) + '\n' + toMin(aud.currentTime));
mplayer.addEventListener('click', () => aud.paused ? aud.play() : aud.pause());
fg.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () =>fg.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>fg.style.animationPlayState = 'paused');
</script>
<style type="text/css">#lrc {
--state: paused;
--motion: cover2;
--tt: 2s;
--bg: linear-gradient(180deg, #880000, #880000);
position: absolute;z-index: 4;
left: 50%;
transform: translate(-50%);
top: 85%;
font:normal 3em 华文隶书;
color: #000078;
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 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</style>
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `
问一问时光 - 魏佳艺
词:孔垂周
曲:木子非
编曲:微笑
吉他:Tommy Zhou
童声:陈泓悦
和声:小雪人
混音/母带:羽晟
制作人:宫轩宇
企划/统筹:宫臣波
发行:亚伦影音
爱也罢 恨也罢 这身皮囊
喜怒哀乐 人生多寻常
南也走 北也闯 我随风飘荡
初心还剩 几斤又几两
我问一问时光 人生路有多长
年少时的理想 换来满身的沧桑
半生兜兜转转 两手还是空荡荡
回首前尘只剩下悲凉
我问一问时光 叹世间苦太长
回不到家乡 我只能遥望
心中爱的人啊 如今你身在何方
不如把念想 谈笑中淡忘
看不惯 抵不过 岁月荒唐
酸甜苦辣 都曾尝一尝
来人间 走一趟 都各自匆忙
谁的人生没有过迷惘
我问一问时光 人生路有多长
年少时的理想 换来满身的沧桑
半生兜兜转转 两手还是空荡荡
回首前尘只剩下悲凉
我问一问时光 叹世间苦太长
回不到家乡 我只能遥望
心中爱的人啊 如今你身在何方
不如把念想 谈笑中淡忘
我问一问时光 人生路有多长
年少时的理想 换来满身沧桑
半生兜兜转转 两手还是空荡荡
回首前尘只剩下悲凉
我问一问时光 叹世间苦太长
回不到家乡 我只能遥望
心中爱的人啊 如今你身在何方
不如把念想 谈笑中淡忘
`;
/*变量 :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); /*获得歌词数组*/
})();
</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 = '';imagee.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 image = document.getElementById("an"),
imagee = document.getElementById("testImg"),
button = document.getElementById("mplayer");
if (imagee &&image && button) {
button.onclick = function() {
if (this.value == '') {
image.play(); imagee.classList.remove('st');
this.value = '.';
} else {
image.stop(); imagee.classList.add('st');
this.value = '';
}
};
}
</script>
这歌曲倒是和架子鼓的敲击节奏很相配呢。欣赏亚伦老师好帖{:4_199:} 欣赏美帖,好听好看,欣赏收藏了!{:4_190:} 亚伦老师棒棒哒!{:4_187:}{:4_187:}{:4_187:} 欣赏老师的美帖,漂亮!{:4_187:}
页:
[1]