亚伦影音工作室 发表于 2024-12-30 05:54

杏花落(Live 合唱版)-胡蜜丹[小辣椒音乐提供]

本帖最后由 亚伦影音工作室 于 2024-12-30 05:54 编辑 <br /><br /><style>
#papa { margin: 140px 0 20px calc(50% - 721px); background:#800 url(https://pic1.imgdb.cn/item/67715fb8d0e0a243d4ec337e.png)no-repeat center/cover;width: 1286px; height: 720px;   box-shadow: 3px 3px 6px gray; overflow: hidden; z-index: 1; position: relative; display: grid; place-items: center; }

#but{top:34%; left:58%; position: absolute;}
#pic{position:absolute;top:53px; left:118px;background: url(https://pic1.imgdb.cn/item/676a527ad0e0a243d4e9066e.png) no-repeat 0px 0px/cover;
      width:68px;
      height: 68px;cursor: pointer;z-index: 8;}
#picc{opacity:0;}
#cndpt{position: absolute; width: 500px; height: 160px;
background:url(https://pic1.imgdb.cn/item/676a5065d0e0a243d4e90325.gif)no-repeat center/100% 100%; border-radius: 8px;
}
#enopg{ position: absolute;width: 500px; height: 160px; opacity:0;
background:url(https://pic1.imgdb.cn/item/676a5961d0e0a243d4e91abe.png)no-repeat center/100% 100%; border-radius: 8px;
}
#tmsg{position: absolute;width: 100px; height: 60px;font: normal 12px sans-serif;color: #fff;top:28px; left:210px;z-index: 8;}
#lrc {--state: paused;--motion: cover2;--tt: 2s;--bg: linear-gradient(0deg, #880000, #880000, #880000);
position: absolute;z-index: 16;left: 50%; top: 86%;transform: translate(-50%);font:400 3.5em/1em 华文行楷;font-style:italic; 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: 100%; height: 100%;color: transparent;overflow: hidden;white-space: pre;background: var(--bg);clip-path: inset(0 100% 0 0);-webkit-background-clip: text;animation: var(--motion) var(--tt) linear forwards;animation-play-state: var(--state);}
@keyframes cover1{ to { clip-path: inset(0 0 0 0); } }@keyframes cover2 { to { clip-path: inset(0 0 0 0); } }
</style>
<div id="papa">
<div id="but" >
<div id="pic"><div id="picc"></div></div>
<div id="tmsg">00:00 | 00:00</div>
<div id="cndpt"></div>
<div id="enopg" ></div>
</div>
<div data-lrc="" id="lrc"></div>
</div>
<audio id="aud" src="https://aod.cos.tx.xmcdn.com/storages/590b-audiofreehighqps/12/CA/GKwRIasLG542ACAAAAM2UhPW.m4a" autoplay loop></audio>
<script >
pic.onclick = () => aud.paused ? (aud.play(),picc.style.opacity= '0',pic.style.opacity = '1',enopg.style.opacity= '0',cndpt.style.opacity = '1'): (aud.pause(),picc.style.opacity = '1',pic.style.opacity = '0',enopg.style.opacity = '1',cndpt.style.opacity = '0');
aud.addEventListener('timeupdate', () => {
                tmsg.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);});
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;
      };

</script >
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `杏花落(Live 合唱版)-胡蜜丹
词:崔伟立
曲:崔伟立
录音:袁涛
编曲:冯丹
笛子:丁晓逵
伴唱:凌菲
混音:苏洲
制作人:冯丹
监制:鑫明
古筝:丁雪儿   
天边那片洁白的云朵
在我身边轻轻地飘过
你像三月暖暖的春风
融化冰冻的小河
你的手我紧紧地牵着
多少风雨也不曾闪躲
真心真意浇灌的花朵
开出万紫千红的颜色
漫天飘飘洒洒的杏花落
温暖了心窝
每当听你唱甜蜜的情歌
眼泪就一颗颗
漫天飘飘洒洒的杏花落
唯美了承诺
陪你走过一生的坎坷
让那爱情开出幸福的果
。。。。。。
天边那片洁白的云朵
在我身边轻轻地飘过
你像三月暖暖的春风
融化冰冻的小河
你的手我紧紧地牵着
多少风雨也不曾闪躲
真心真意浇灌的花朵
开出万紫千红的颜色
漫天飘飘洒洒的杏花落
温暖了心窝
每当听你唱甜蜜的情歌
眼泪就一颗颗
漫天飘飘洒洒的杏花落
唯美了承诺
陪你走过一生的坎坷
让那爱情开出幸福的果
漫天飘飘洒洒的杏花落
温暖了心窝
每当听你唱甜蜜的情歌
眼泪就一颗颗
漫天飘飘洒洒的杏花落
唯美了承诺
陪你走过一生的坎坷
让那爱情开出幸福的果
让那爱情开出幸福的果
谢谢欣赏

`;
/*变量 :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')) : (lrc.style.setProperty('--state','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>



秋思梦景 发表于 2024-12-30 08:03

问候老师好!精美音画佳作,精心制作分享!为您点赞!祝您新年快乐!{:4_187:}{:5_108:}

杨帆 发表于 2024-12-30 09:57

控制按钮别致,视听盛宴,谢谢亚伦老师精彩分享{:4_191:}

红影 发表于 2024-12-30 10:14

这个播放器按钮按动之前和之后变化还挺大呢,漂亮。
频谱和歌词同步也很漂亮{:4_199:}

红影 发表于 2024-12-30 10:14

欣赏亚伦老师的精美制作{:4_199:}

梦油 发表于 2024-12-30 10:51

欣赏佳作,问候亚伦。

小辣椒 发表于 2024-12-30 14:06

哈哈~~~亚伦又来一个漂亮的播放器{:4_199:}

老谟深虑 发表于 2024-12-30 14:53

         这个按钮真漂亮,欣赏点赞!
页: [1]
查看完整版本: 杏花落(Live 合唱版)-胡蜜丹[小辣椒音乐提供]