怒放的生命 TO:亚伦
<style>
#papa { margin: 120px -370px ;width: 1327px; height: 759px; background:#000000 url('https://xlaj.cn/assets/file/zp/20230802015717.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; top:10px; display: grid; place-items: center; overflow: hidden; user-select: none; z-index: 1;}
#dt{ position: absolute; width: 1288px; height: 754px; top: 0px; left: 0px; }
#mplayer {position: absolute;grid-template-areas: 'cur btnplay dur''prog prog prog';gap: 8px 4px;display: grid;place-items: end center;color: var(--color);font: normal 16px sans-serif;z-index: 999;--bgColor: linear-gradient(to right, var(--prog) 0%, var(--prog) 0%, var(--track) 0%, var(--track));--ww: 900px;--color: hsla(100,10%,80%,.95);--track: hsla(90, 100%, 95%, .65);--prog: hsla(50,50%,50%,.65);--btn_size: 40px;}
#btnplay {--dis1: block;--dis2: none;grid-area: btnplay;width: 35px;height: 35px;border: 3px solid var(--color);border-radius: 50%;opacity: .95;cursor: pointer;transition: .3s;position: relative;}
#btnplay:hover { opacity: 1; box-shadow: 0 0 5px var(--color), inset 0 0 5px var(--color); }
#btnplay:hover::before, #btnplay:hover::after { opacity: 1; }
#btnplay::before, #btnplay::after {position: absolute;content: '';width: 100%;height: 100%;background: var(--color);opacity: .85;}
#btnplay::before { display: var(--dis1); clip-path: polygon(35% 30%, 75% 50%, 35% 70%); }
#btnplay::after {display: var(--dis2);clip-path: polygon(35% 30%, 45% 30%, 45% 70%, 35% 70%, 55% 70%, 65% 70%, 65% 30%, 55% 30%, 55% 70%, 35% 70%);}
#prog {grid-area: prog;-webkit-appearance: none;width: var(--ww);outline: none;background: none;position: relative;}
#prog::-webkit-slider-thumb {-webkit-appearance: none;position: relative;width: 20px;height: 20px;border: 6px solid var(--color);border-radius: 50%;background: var(--prog);top: calc(50% - 10px);cursor: pointer;z-index: 8;}
#prog::-webkit-slider-runnable-track { height: 4px; border-radius: 10px; background: var(--bgColor); }
#prog::-moz-range-track { height: 4px; border-radius: 10px; background: var(--bgColor); }
#cur { grid-area: cur; color: var(--color); position: absolute;left:0%;}
#dur { grid-area: dur; color: var(--color);position: absolute; left:90%;}
#lrc {
--state: paused;
--motion: cover2;
--tt: 2s;
--bg: linear-gradient(180deg, #880000, #880000)no-repeat center/cover;
position: absolute;
left: 49%;z-index: 20;
transform: translate(-50%);
top: 10%;
font:normal 2.8em 华文隶书;
color: #0000;
white-space: pre;
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%;letter-spacing: 15px; color:#000090;}100% { width: 350%; letter-spacing: 0px;color:#ff0000; } }
@keyframes cover2 {0% { width: 0%;letter-spacing: 0px; color:#00ff00;}100% { width: 350%; letter-spacing: 15px;color:#ff0000; }}
#papa:hover #fullscreen { display:block ;}
#fullscreen { position: absolute; top:5%; left:80%;color:#FFffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 3em华文隶书; opacity: 1; cursor: pointer; z-index: 111}
</style>
<div id="papa">
<img id="dt" src="https://xlaj.cn/assets/file/zp/20230802015628.gif" alt="" style=" " />
<div id="lrc" data-lrc="怒放的生命">怒放的生命</div>
<div id="mplayer">
<input type="range" id="prog" step="0.1" max="100" value="0" /><span id="btnplay"></span><span id="cur">00:00</span><span id="dur">00:00</span>
</div>
<audio id="aud" src="https://wj1.zp68.com:812/lxx/yunhua/2022/07/14/001.mp3" autoplay loop></audio>
</div>
<script>
(function(mkPlayer) {let defaults ={player_css: `bottom: 40px;left: 20%; --color: white; --ww: 900px; --track: snow; --prog: purple;`};let playCode = (user_config) => {let data = Object.assign({}, defaults, user_config);papa.innerHTML += data.playerCode;mplayer.style.cssText += data.player_css;lrc.style.cssText += data.lrc_css;let mKey = 0, mFlag = true, mDrag = false;btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();prog.onmousedown = () =>mDrag =true;prog.onmouseout = () => mDrag = false;prog.onchange = () => { aud.currentTime = aud.duration * prog.value / 100; mDrag = false; };prog.onmousemove = () => prog.style.setProperty('--bgColor', `linear-gradient(to right, var(--prog) 0%, var(--prog) ${prog.value}%, var(--track) ${prog.value}%, var(--track))`);aud.addEventListener('timeupdate', () => {cur.innerText = toMin(aud.currentTime);dur.innerText = toMin(aud.duration);prog.style.setProperty('--bgColor', `linear-gradient(to right, var(--prog) 0%, var(--prog) ${prog.value}%, var(--track) ${prog.value}%, var(--track))`);if(mDrag===false) prog.value = aud.currentTime / aud.duration * 100;for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {cKey = j;if (mKey === j) showLrc(data.lrcAr);else continue;}}});let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),btnplay.style.setProperty('--dis1','block'), btnplay.style.setProperty('--dis2','none')): (lrc.style.setProperty('--state','running'),btnplay.style.setProperty('--dis1','none'), btnplay.style.setProperty('--dis2','block'));aud.addEventListener('pause', () => mState());aud.addEventListener('play', () => mState());aud.addEventListener('seeked', () => calcKey());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;}};mkPlayer.HCPlayer = playCode;})(this);HCPlayer();
(function() {let toMin = (val) => { if (!val) return '00:00'; let min = parseInt(val / 60), sec = parseFloat(Math.floor(val) % 60); if(sec < 10) sec = '0' + sec; return min + ':' + sec; }
aud.addEventListener('timeupdate', () => { prog.style.setProperty('--prg', aud.currentTime / aud.duration * 100 + '%');
prog.dataset.cu = toMin(aud.currentTime); prog.dataset.du = toMin(aud.duration); });
mplayer.addEventListener('click', () => { aud.paused ?aud.play() : aud.pause(); });
})();
(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'),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>
<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 image= document.getElementById("dt"),
button = document.getElementById("mplayer");
if (image&& button) {
button.onclick = function() {
if (this.value == '') {
image.play();
this.value = '.';
} else {
image.stop();
this.value = '';
}
};
}
</script>
谢谢亚伦的代码,我就加了底图,没有底图手机看见是黑的,去了一行代码,其他下面的那些代码我不熟也是不懂就没有改。 汪峰的歌,基本不听。帖子漂亮。 马黑黑 发表于 2023-8-3 21:33
汪峰的歌,基本不听。帖子漂亮。
哈哈~~~这歌我是现成的,旧图图秒做的{:4_170:} 小辣椒 发表于 2023-8-3 21:45
哈哈~~~这歌我是现成的,旧图图秒做的
速度 醉美水芙蓉 发表于 2023-8-3 21:41
漂亮!
谢谢水芙蓉欣赏,套用亚伦的代码做的{:4_173:} 马黑黑 发表于 2023-8-3 21:46
速度
马上10点了,所以必须赶时间的 动感的歌和舞,好听好看又提神{:4_187:} 汉子美女扭得挺带劲,挺有趣的{:4_173:}{:4_187:} 问好小辣椒,好久不见:{:4_179:} 好热烈的画面,非常适合这首歌呢。欣赏亲爱的好帖。亚伦老师收礼开心{:4_187:} 小辣椒 发表于 2023-8-3 21:48
马上10点了,所以必须赶时间的
也是 小辣椒 发表于 2023-8-3 21:30
谢谢亚伦的代码,我就加了底图,没有底图手机看见是黑的,去了一行代码,其他下面的那些代码我不熟也是不懂 ...
动感实足,好喜欢辣椒的动图,有时间借用一下! 小辣椒的贴子活力实足,小线播被你整的大气得很,画面十分协调,喜欢!{:4_187:} 千羽 发表于 2023-8-3 22:05
动感的歌和舞,好听好看又提神
千羽其实也是蛮懂音乐的{:4_204:} 千羽 发表于 2023-8-3 22:09
问好小辣椒,好久不见:
好久不见,先大大的{:4_179:} 红影 发表于 2023-8-3 22:18
好热烈的画面,非常适合这首歌呢。欣赏亲爱的好帖。亚伦老师收礼开心
亲爱的,其实以前动感音乐我也是很少做,特别DJ,我怕烦,纯为动图而加的{:4_170:} 马黑黑 发表于 2023-8-3 22:45
也是
黑黑好{:4_187:} 亚伦影音工作室 发表于 2023-8-3 22:51
动感实足,好喜欢辣椒的动图,有时间借用一下!
没事,你玩,只是我加了自己的logo了
页:
[1]
2