马黑黑 发表于 2022-9-20 07:25

外面的世界

<style>
        #papa { left: -214px; width: 1024px; height: 640px; background: #ccc url('https://638183.freep.cn/638183/Pic/2022/osworld.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; display: grid; place-items: center; overflow: hidden; position: relative; z-index: 1; }
        #mplayer { position: absolute; left: 10px; bottom: 10px; }
        #btnwrap { fill: snow; cursor: pointer; }
        #btnwrap:hover { fill: olive; }
        #tmsg { fill: snow; stroke: gray; stroke-width: 1px; font: bold 1em sans-serif; }
        #lrc { position: absolute; bottom: 50px; left: 140px; font: bold 2em sans-serif; color: transparent; letter-spacing: 2px; background: linear-gradient(-90deg, darkgreen, orange, tomato) 100% 100% / 200% 200%; background-clip: text; -webkit-background-clip: text; }
        #lbee { position: absolute; left: 100px; top: 50px; }
        @keyframes bgMove1 { from { background-position: 0 0; } to { background-position: -100% 0; } }
        @keyframes bgMove2 { from { background-position: 0 0; } to { background-position: -100% 0; } }
</style>

<div id="papa">
        <img id="lbee" src="https://638183.freep.cn/638183/Pic/2022/bee01.gif" alt="" />
        <div id="lrc">花潮lrc在线</div>
        <svg id="mplayer" width="120" height="120">
                <g id="mama" transform="rotate(-90, 60, 60)" style="cursor: pointer">
                        <circle id="track" cx="60" cy="60" r="50" fill="none" stroke-width="10" stroke="rgba(255,255,255,0.65)" />
                        <circle id="prog" cx="60" cy="60" r="50" fill="none" stroke-width="6" stroke="rgba(57,54,81,0.85)" />
                </g>
                <g id="btnwrap">
                        <path id="btnplay" d="M 50 50,50 70,70, 60 z"></path>
                        <path id="btnpause" d="M 52 50,52 70,57 70,57 50,52 50 z M 60 50,60 70,65 70,65 50,60 50 z" style="display:none"></path>
                        <path d="M 57 50,60 50,60 70,57 70 z" fill="transparent" />
                </g>
                <path id="curPath" d="M 20 70 Q 60 0 100 70" fill="none" stroke="none"/>
                <path id="durPath" d="M 20 55 Q 60 110 100 55" fill="none" stroke="none"/>
                <g id="tmsg">
                        <text x="34" y="0"><textPath id="curMsg" xlink:href="#curPath" dominant-baseline="text-after-edge">00:00</textPath></text>
                        <text x="29" y="0"><textPath id="durMsg" xlink:href="#durPath" dominant-baseline="text-before-edge">00:00</textPath></text>
                </g>
        </svg>
</div>

<script>
let lrcAr = [
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
       
];
let mKey = 0, mFlag = true, aud = new Audio();
let cc = {
        x: 1*track.getAttribute('cx'),
        y: 1*track.getAttribute('cy'),
        r: 1*track.getAttribute('r'),
        len: track.getTotalLength(),
};

prog.style.strokeDasharray = prog.style.strokeDashoffset =cc.len;
aud.src = 'https://music.163.com/song/media/outer/url?id=473285827.mp3';
aud.autoplay = true;
aud.loop = true;

mama.onclick = (e) => {
        let deg = Math.atan2(e.offsetY - cc.y, e.offsetX - cc.x) * 180 / Math.PI;
        deg += (e.offsetX < cc.x && e.offsetY < cc.y) ? 450 : 90;
        aud.currentTime = aud.duration * deg / 360;
};

btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();

aud.addEventListener('pause', () => mState());
aud.addEventListener('play', () => mState());
aud.addEventListener('seeked', () => calcKey());

aud.addEventListener('timeupdate', () => {
        prog.style.strokeDashoffset = cc.len - cc.len * aud.currentTime / aud.duration;
        curMsg.textContent = toMin(aud.currentTime);
        durMsg.textContent = toMin(aud.duration);
        for(j=0; j<lrcAr.length; j++) {
                if(aud.currentTime >= lrcAr) {
                        if(mKey === j) showLrc(lrcAr);
                        else continue;
                }
        }
});

let mState = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none', lrc.style.animationPlayState = 'paused') : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc.style.animationPlayState = 'running');

let showLrc = (time) => {
        lrc.style.animation = (mFlag ? 'bgMove1 ' : 'bgMove2 ') + time + 's linear forwards';
        lrc.innerHTML = lrcAr;
        mKey += 1;
        mFlag = !mFlag;
}

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 mtime = lrcAr - (aud.currentTime - lrcAr);
        showLrc(mtime);
}

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>

马黑黑 发表于 2022-9-20 07:31

本帖并无实现机制方面的变化,非常简单,代码就不贴出来了。发布它主要原因:

① 感觉这首歌很不错;

② 检验一下正在着手做了一小半的微调加餐歌词的效果。

上海朝阳 发表于 2022-9-20 08:41

给姑娘的秀发上加一朵鲜花,引得蜜蜂团团转

上海朝阳 发表于 2022-9-20 08:55

【为了配合技术大人的节奏,连夜把空间升级成linux环境,原来空间的所有资料全部得搬家,明天解析成https,带来的问题是,以前资料的连接都断连了,也不再去改了,主要是我也不知道在哪个帖子里有连接了。】

老马,我的朋友遇到这个问题,你能帮助解惑吗?我不太懂这些技术活。

红影 发表于 2022-9-20 09:54

这个小蜜蜂有趣。歌词加餐的精准度都到小数点后面两位了,居然那么精确啊{:4_187:}

红影 发表于 2022-9-20 09:56

我现在听不了歌,也不知道怎么精准后的效果到底如何{:4_173:}

醉美水芙蓉 发表于 2022-9-20 11:37

马黑黑 发表于 2022-9-20 12:11

醉美水芙蓉 发表于 2022-9-20 11:37
欣赏学习黑黑老师佳作!

感谢支持

马黑黑 发表于 2022-9-20 12:12

上海朝阳 发表于 2022-9-20 08:41
给姑娘的秀发上加一朵鲜花,引得蜜蜂团团转

蜜蜂要出去看看外面的世界

马黑黑 发表于 2022-9-20 12:12

红影 发表于 2022-9-20 09:56
我现在听不了歌,也不知道怎么精准后的效果到底如何

应该挺好的

马黑黑 发表于 2022-9-20 12:14

上海朝阳 发表于 2022-9-20 08:55
【为了配合技术大人的节奏,连夜把空间升级成linux环境,原来空间的所有资料全部得搬家,明天解析成https, ...

这个需要等待。服务器系统换了,数据迁移是提供商的事情,迁移成功后还要等,DNS服务器的刷新需要时间。

请按照提供商的要求去做一些配合的工作,如果有。

马黑黑 发表于 2022-9-20 12:15

红影 发表于 2022-9-20 09:54
这个小蜜蜂有趣。歌词加餐的精准度都到小数点后面两位了,居然那么精确啊

两位多了,可以只需一位。微调程序还在开发中

加林森 发表于 2022-9-20 13:59

英王去世了,要向蜜蜂报告!

红影 发表于 2022-9-20 16:04

马黑黑 发表于 2022-9-20 12:15
两位多了,可以只需一位。微调程序还在开发中

两位好,感觉更准确{:4_173:}

红影 发表于 2022-9-20 16:05

马黑黑 发表于 2022-9-20 12:12
应该挺好的

那是肯定的,黑黑花了那么多精力的呢{:4_187:}

小辣椒 发表于 2022-9-20 17:19

哎呀,手机加分点击错误,明明黒黑的原创,怎么会山寨呢{:4_189:}

小辣椒 发表于 2022-9-20 17:21

马黑黑 发表于 2022-9-20 07:31
本帖并无实现机制方面的变化,非常简单,代码就不贴出来了。发布它主要原因:

① 感觉这首歌很不错;


播放器和昨天的一样的,歌词颜色这个漂亮,这个可以2个完成一个作业吧

小辣椒 发表于 2022-9-20 17:22

马黑黑 发表于 2022-9-20 12:12
应该挺好的

这歌我也是挺喜欢的

小辣椒 发表于 2022-9-20 17:23

每天这个时候可以上来瞄一眼

小辣椒 发表于 2022-9-20 17:26

小蜜蜂我得电脑才可以看看黒黑怎么上去的,这个是动图还是路径
页: [1] 2 3 4 5 6 7
查看完整版本: 外面的世界