亚伦影音工作室 发表于 2024-3-12 11:29

还没认真年轻就要变老-魏佳艺

本帖最后由 亚伦影音工作室 于 2024-4-17 13:09 编辑 <br /><br /><style type="text/css">
#papa{
        position: relative;
        width: 1164px;
        height: 640px;
      margin-left:-300px;
        margin-top:140px;
        border: 0px solid rgba(36, 201, 219,.95);
      border-radius: 10px;
        background:url(https://pic.imgdb.cn/item/65db15889f345e8d03a7d9b2.jpg)no-repeat center/cover,linear-gradient(40deg, #000000, #00ff00, #000080, #ff0000);
        overflow: hidden;
}
#prog { position: absolute; bottom: 550px;left:65px; width: 280px; height: 5px; background: linear-gradient(to right, #880000, #880000 var(--prg), white 0); color: snow; display: grid; place-items: center; --prg: 0%; --state: paused;border-radius: 2px;}
#prog::before, #prog::after { position: absolute;color: #ffffff; font:normal 1em 华文新魏;}
#prog::before { content: attr(data-cu); left:5px; top: -25px; }
#prog::after { right: 5px; content: attr(data-du); ; top: -25px; }
#slider { position: absolute; width: 6px; height: 6px; background: #cccccc;box-shadow: 0px 0px 0px 4px #880000; left: var(--prg); border-radius: 50%; }
#btnplay { position: absolute; top: -70px; width: 50px; height: 50px; background: url('https://s7.krakenfiles.com/uploads/17-04-2024/VMfBIxGHy2/image.png') no-repeat center/cover; cursor: pointer; animation: rot 6s infinite linear var(--state); }
@keyframes rot { to { transform: rotate(1turn); filter: hue-rotate(360deg);} }
.photo {width: 1164px; height: 640px;
position: absolute;
top:0%; left:0%;
opacity: 0;
animation: round 90s linear infinite;}
@keyframes round{
0% {
opacity: 1;clip-path: ellipse(0% 00% at 50% 50%);
-webkit-transform:translate(0%,0%)scale(1)
}

2% {
opacity: 1;clip-path:ellipse(1% 1% at 50% 50%);
-webkit-transform:translate(0%,0%)scale(1)
}
6% {
opacity: 1;clip-path: ellipse(50% 50% at 50% 50%);
-webkit-transform:translate(0%,0%)scale(1);
}

8% {clip-path: ellipse(100% 100% at 50% 50%);
-webkit-transform:translate(0%,0%)scale(1);
opacity: 1;}

12% {clip-path: ellipse(100% 100% at 50% 50%);
-webkit-transform:translate(0%,0%)scale(1);
opacity: 1;}
14% {clip-path: ellipse(100% 100% at 50% 50%);
-webkit-transform:translate(0%,0%)scale(1);
opacity: 0;}
}
.photo:nth-child(15) {animation-delay: 84s;background: url(https://pic.imgdb.cn/item/65db15889f345e8d03a7d9b2.jpg)no-repeat center/cover}
.photo:nth-child(14) {animation-delay: 78s;background: url(https://pic.imgdb.cn/item/65db15639f345e8d03a787ea.jpg)no-repeat center/cover}
.photo:nth-child(13) {animation-delay: 72s;background: url(https://pic.imgdb.cn/item/65db15639f345e8d03a78720.jpg)no-repeat center/cover}
.photo:nth-child(12) {animation-delay: 66s;background: url(https://pic.imgdb.cn/item/65db15629f345e8d03a78591.jpg)no-repeat center/cover}
.photo:nth-child(11) {animation-delay: 60s;background: url(https://pic.imgdb.cn/item/65db13539f345e8d03a32d0b.jpg)no-repeat center/cover}
.photo:nth-child(10) {animation-delay: 54s;background: url(https://pic.imgdb.cn/item/65db13fa9f345e8d03a48992.jpg)no-repeat center/cover}
.photo:nth-child(9) {animation-delay: 48s;background: url(https://pic.imgdb.cn/item/65db12cb9f345e8d03a20693.jpg)no-repeat center/cover}
.photo:nth-child(8) {animation-delay: 42s;background: url(https://pic.imgdb.cn/item/65dac8db9f345e8d03eac742.jpg)no-repeat center/cover}
.photo:nth-child(7) {animation-delay: 36s;background: url(https://pic.imgdb.cn/item/65bb5ce1871b83018a3ed949.jpg)no-repeat center/cover}
.photo:nth-child(6){animation-delay: 30s;background: url(https://pic.imgdb.cn/item/65b8fae0871b83018a629f5a.jpg)no-repeat center/cover}
.photo:nth-child(5){animation-delay: 24s;background: url(https://pic.imgdb.cn/item/65b8fa8e871b83018a610f7f.jpg)no-repeat center/cover}
.photo:nth-child(4){animation-delay: 18s;background: url(https://pic.imgdb.cn/item/658d7b30c458853aefc07335.jpg)no-repeat center/cover}
.photo:nth-child(3){animation-delay: 12s;background: url(https://pic.imgdb.cn/item/658c0a24c458853aef9d89ab.jpg)no-repeat center/cover}
.photo:nth-child(2) {animation-delay: 6s;background: url(https://pic.imgdb.cn/item/658c09d6c458853aef9c646b.jpg)no-repeat center/cover}
.photo:nth-child(1) {animation-delay: 0s;background: url(https://pic.imgdb.cn/item/658c1095c458853aefb7e2e9.jpg)no-repeat center/cover}
.stop .photo:nth-child(1),
.stop .photo:nth-child(2),
.stop .photo:nth-child(3),
.stop .photo:nth-child(4),
.stop .photo:nth-child(5),
.stop .photo:nth-child(6),
.stop .photo:nth-child(7),
.stop .photo:nth-child(8),
.stop .photo:nth-child(9),
.stop .photo:nth-child(10),
.stop .photo:nth-child(11),
.stop .photo:nth-child(12),
.stop .photo:nth-child(13),
.stop .photo:nth-child(14),
.stop .photo:nth-child(15){animation-play-state: paused;}

#lrc {
        --motion: cover2;
        --tt: 1s;
        position: absolute;
        left: 50%;
        top: 85%;
        transform: translate(-50%, 0px)skew(0deg);
                font:normal 3.5em 华文隶书;
        color:#0000;
        filter:hue-rotate(0deg)contrast(120%)brightness(200%);
        filter: drop-shadow( 2px 2px 0px #ffffff);
        z-index: 2;
       
}

#lrc::before {
        position: absolute;
        content: attr(data-lrc);
        width: 20%;
        height: 100%;
        color: transparent;
        overflow: hidden;
        white-space: pre;
        background:#E00000 ;
        filter: drop-shadow( 0px 0px 1px #ffffff)drop-shadow( 0px 0px 1px #ffffff)drop-shadow( 0px 0px 1px #ffffff)drop-shadow( 0px 0px 1px #ffffff);
        -webkit-background-clip: text;
        animation: var(--motion) var(--tt) linear forwards;
        animation-play-state: var(--state);
        }   

@keyframes cover1{
        0% { width: 300%;letter-spacing: 0px; height: 0;transform: skew(0deg);color:#000080;}
        to { width: 300%;height: 300%;transform: skew(0deg);}
}
@keyframes cover2 {
        0% { width: 300%;letter-spacing: 0px; height: 0; transform: skew(0deg);color:#000080;}
        100% { width: 300%; height: 300%; transform: skew(0deg)}
}

</style >
<div id="papa" >
<div id="testImg" >
<pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p><pclass="photo"></p>
</div>
<audio autoplay="" id="aud" loop="" src="https://s8.krakenfiles.com/uploads/17-04-2024/XVC95jcWhj/music.m4a">&nbsp;</audio>
<div id="prog" data-cu="00:00" data-du="00:00" title="调节进度">
      <span id="btnplay" title="播放/暂停"></span>
      <span id="slider"></span>
    </div>
<div data-lrc="亚伦影音工作室" id="lrc" title="歌词显示">亚伦影音工作室</div>
</div>
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `还没认真年轻就要变老-魏佳艺
词:唐心语
曲:王家军
编曲:原始部落@王亚东
混音:原始部落@LeoD
吉他:原始部落@LeoD
和声:原始部落@小佑
制作人:亚伦
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); /*获得歌词数组*/
})();
</script>
<script>
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 = () => prog.style.setProperty('--state', aud.paused ? 'paused' : 'running');
aud.addEventListener('pause', mState, false);
aud.addEventListener('play', mState, false);
aud.addEventListener('timeupdate', () => { prog.style.setProperty('--prg', aud.currentTime / aud.duration * 100 + '%'); prog.dataset.cu = toMin(aud.currentTime); prog.dataset.du = toMin(aud.duration); });
btnplay.onclick = (e) => { e.stopPropagation(); aud.paused ?( aud.play(),vid.play() ):( aud.pause(),vid.pause()); }
prog.onclick = (e) => aud.currentTime = e.offsetX * aud.duration / prog.offsetWidth;
vid=document.querySelector('#vid');
(function(){
var image = document.getElementById("testImg");
let mState = () => aud.paused ? (image.classList.add('stop')):(image.classList.remove('stop'));
aud.addEventListener('play', () => mState());
aud.addEventListener('pause', () => mState());
})();
</script>



世外桃源 发表于 2024-3-12 12:03

还没认真年轻就要变老{:4_199:}

世外桃源 发表于 2024-3-12 12:03

欣赏老师佳作{:4_187:}

世外桃源 发表于 2024-3-12 12:03

感谢分享

老谟深虑 发表于 2024-3-12 16:36

         欣赏老师的佳作,点赞!请老师能把这个代码在离退休论坛发表,我好学习制作。谢谢!

红影 发表于 2024-3-12 20:04

这个效果很漂亮呢,欣赏亚伦老师好帖{:4_199:}

红影 发表于 2024-3-12 20:06

这个开始时候特别清爽,好像播放一段时间大约一分钟后,画面就开始有闪烁的杂色。不知道是不是我电脑问题{:4_203:}

红影 发表于 2024-3-12 20:06

这首歌词很有道理,还是第一次听呢{:4_187:}

小辣椒 发表于 2024-3-12 21:07

欣赏亚伦新的特效{:4_187:}
页: [1]
查看完整版本: 还没认真年轻就要变老-魏佳艺