亚伦影音工作室 发表于 2023-9-26 15:39

祝红影双节快乐!

本帖最后由 亚伦影音工作室 于 2023-9-26 16:11 编辑 <br /><br /><style >
#papa{margin: 10px -300px ;width: 1164px;overflow: hidden;height: 640px;background: url(https://)repeat center/100% 100%;position: relative;z-index: 20;}
#biank{width:70%;height:70%;position: absolute;top:3%; left:5%;box-shadow: 0px 0px 0px 2px #ffffff, 0px 0px 0px 4px #000000; overflow: hidden;background:linear-gradient(0deg, #000000 2%,#000000 8%,rgba(2, 2, 2, 0) 30%,rgba(52, 152, 219, 0) 100%,rgba(2, 2, 2, 0) 100%,black 100%),url('https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/eff3e42dd705185b70c65627647fe1ae.jpg') center/cover no-repeat;z-index: 2;}
#biank:hover #fullscreen { display:block ;}
#fullscreen { position: absolute; top:5%; left:80%;color:#FFffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2em华文行楷; opacity: 1; cursor: pointer; z-index: 111}
#dt{position: absolute;top:0%; left:0%;z-index: 2;
      width:100%;mix-blend-mode:hard-light;
      height:100%; transition: .3s all ease;}
#mplayer {width:440px;height:440px;position: absolute;top:25px; left:650px;box-shadow:0px 0px 0px 2px #ffffff, 0px 0px 0px 4px #000000;border-radius:50%; animation:rotating 10s linear infinite;background: url('https://pic.imgdb.cn/item/642fd02ca682492fcc557b12.png') no-repeat center/cover;z-index: 2;}
@keyframes rotating{to {transform:rotate(360deg); }}
#papa:hover #mplayer { display:block ;}
#audio{top:88%; left:0%;z-index: 6;
position: absolute;
width:100%;
cursor: pointer;
mix-blend-mode:lighten; filter:invert(100%)
}
#flyBox { --w: 90%; width: var(--w); overflow: hidden; color: #cccccc; position: absolute; left:3%;top:95%;font-size: 12px; z-index: 36;}
#flyBox div { word-break: keep-all; white-space: nowrap; animation: fly 60s linear infinite; background:#0000}
@keyframes fly { from { transform: translateX(100%); } to { transform: translateX(calc(0% - var(--w))); }}
</style>
<div id='papa'>
<divid="mplayer" ></div>
<div id='biank'>
<span id="fullscreen">全屏观赏</span>

<div id='dt'><img id="testImg" src="https://www.yiyuen.com/e/file/view/638024" width="100%" height="100%"></div>
<div id="lrc" data-lrc="亚伦影音工作室">亚伦影音工作室</div>

<div id='audio'>
<audio id="aud" src="https://www.qqmc.com/mp3/music295406824.mp3"style="width:100%;"autoplay="autoplay" controls="controls" height="100%" loop="loop"></audio></div>
   <div id="flyBox"><div>人生已过半 (DJ阿哲版) - 魏佳艺
词:宋亚永
曲:陈一龙发行:亚伦影音工作室</div></div>
</div>
</div>

<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("testImg");
varbutton = document.getElementById("mplayer");
let mState = () => aud.paused ?image.stop(): image.play();
aud.addEventListener('play', mState,false);
aud.addEventListener('pause', mState,false);

let fs = true;
      fullscreen.onclick = () => {
                fs ? (fullscreen.innerText = '退出全屏', biank.requestFullscreen()) : (fullscreen.innerText = '全屏观赏', document.exitFullscreen());
                fs = !fs;
      };

</script>
<style>
#lrc {
      --state: paused;
      --motion: cover2;
      --tt: 2s;
      --bg: linear-gradient(180deg, #880000, #880000);
      position: absolute;
      left: 50%;z-index: 20;
      transform: translate(-50%);
      top: 78%;
      font:normal 2.2em 华文隶书;
      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:#000080;}100% { width: 350%; letter-spacing: 0px;color:#ff0000; }}
@keyframes cover2 {0% { width: 0%;letter-spacing: 15px; color:#000080;}100% { width: 350%; letter-spacing: 0px;color:#ff0000; }}

</style>


<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `人生已过半 (DJ阿哲版) - 魏佳艺
词:宋亚永
曲:陈一龙
编曲:陈一龙Music.GZS
吉他:陈一龙Music.GZS
和声:陈一龙Music.GZS
混音:陈一龙Music.GZS
封面设计:左意辰
出品:亚伦影音工作室
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());/*监听查询事件*/
mplayer.addEventListener('click', () =>{ aud.paused ? aud.play() : aud.pause(); });
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();

</script>

梦油 发表于 2023-9-26 16:26

预祝红影双节快乐
预祝亚伦双节快乐
预祝朋友们双节快乐

醉美水芙蓉 发表于 2023-9-26 17:10

红影 发表于 2023-9-26 20:10

多谢亚伦老师,这个制作真漂亮,按帖子里的播放器按钮和旁边的大光盘,都能暂停呢,真神奇{:4_199:}

红影 发表于 2023-9-26 20:10

收到这么美好的节日礼物太开心了{:4_187:}

红影 发表于 2023-9-26 20:11

全屏的时候光盘就不见了,让整个画面都呈现了出来。非常漂亮的制作{:4_199:}

红影 发表于 2023-9-26 20:12

也祝亚伦老师双节快乐,幸福美满{:4_187:}

红影 发表于 2023-9-26 20:13

梦油 发表于 2023-9-26 16:26
预祝红影双节快乐
预祝亚伦双节快乐
预祝朋友们双节快乐

多谢梦油,也祝您双节快乐{:4_187:}

红影 发表于 2023-9-26 20:13

醉美水芙蓉 发表于 2023-9-26 17:10
祝老师节日快乐!

祝水芙蓉美女双节快乐{:4_187:}

梦油 发表于 2023-9-27 11:11

红影 发表于 2023-9-26 20:13
多谢梦油,也祝您双节快乐

影子朋友别客气。

红影 发表于 2023-9-27 13:59

梦油 发表于 2023-9-27 11:11
影子朋友别客气。

饿呢,大家都别客气,一起开心过节{:4_204:}
页: [1]
查看完整版本: 祝红影双节快乐!