亚伦影音工作室 发表于 2023-8-28 17:29

我们都是红尘客 (女声版) - 钰柃[5图轮播可控]

本帖最后由 亚伦影音工作室 于 2023-8-29 11:34 编辑 <br /><br /><style>
#papa{ margin: 10px -300px;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;top:90%;left:2%;cursor: pointer;font: normal 2.3em/0em 华文隶书;
color:#fff000;z-index: 1650;animation: rot 0.5s linear infinite;}
@keyframes rot{0% {opacity: 1;transform: scale(1);}100% {opacity: 1;transform:scale(1);filter:hue-rotate(360deg)contrast(100%)brightness(250%);}}
#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: 85%;
      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: scale(1);filter:blur(1px)}
5% {opacity: 1;transform: scale(1);filter:hue-rotate(360deg)contrast(120%)brightness(120%);}
10% {opacity: 1;transform: scale(1);}
27% {opacity: 1;transform:scale(4)rotateY(0deg);filter:blur(0px)}
28% {opacity: 0;transform:scale(4)rotateY(0deg);filter:blur(2px)}
}
.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;}
#dt{position: absolute;top:0%; left:0%;width: 100%;height: 100%;z-index: 4;mix-blend-mode: lighten; }
#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>

<div id='dt' ><img id="testImg" src="https://pic.imgdb.cn/item/64e9ed69661c6c8e544cbe70.gif" width="100%" height="100%"></div>
<span id="fullscreen">全屏观赏</span>

<div id="lrc" data-lrc="我们都是红尘客">我们都是红尘客</div>
<div id="mplayer" ><span id="bf">暂停</span></div>
                        <audio id="aud" src="https://www.qqmc.com/mp3/music289125966.mp3" autoplay="" loop=""></audio>
</div>

<script >
(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());/*监听查询事件*/
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();
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");
var image= document.getElementById("testImg");
var aud= document.getElementById('aud');
    var mplayer=document.getElementById("bf");
mplayer.onclick = function() {
if ( bf.innerText == '暂停') {
            image.stop();aud.pause(); imagee.classList.add('stop');
          bf.innerText="播放";
      } else {
          image.play();aud.play(); imagee.classList.remove('stop');
            bf.innerText="暂停";
      }
    };

</script>

红影 发表于 2023-8-28 18:35

这个帖子代码命名貌似和论坛有冲突,让论坛的表情出现变化了{:4_204:}

亚伦影音工作室 发表于 2023-8-28 18:46

红影 发表于 2023-8-28 18:35
这个帖子代码命名貌似和论坛有冲突,让论坛的表情出现变化了

能让网页改变很惊讶!

红影 发表于 2023-8-28 19:27

亚伦影音工作室 发表于 2023-8-28 18:46
能让网页改变很惊讶!

最好修改一下出问题的代码。

亚伦影音工作室 发表于 2023-8-29 11:33

红影 发表于 2023-8-28 19:27
最好修改一下出问题的代码。

图片采用自适应显示,手机和电脑同步。

红影 发表于 2023-8-29 14:03

亚伦影音工作室 发表于 2023-8-29 11:33
图片采用自适应显示,手机和电脑同步。

现在好了,亚伦老师真棒{:4_199:}
页: [1]
查看完整版本: 我们都是红尘客 (女声版) - 钰柃[5图轮播可控]