马黑黑 发表于 2022-9-23 07:15

呼伦贝尔

<style>
        #papa { left: -214px; width: 1024px; height: 640px; background: url('/data/attachment/forum/202209/23/071140hqavv7a5d0vd4viv.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; box-shadow: 3px 3px 20px #000; display: flex; justify-content: center; overflow: hidden; position: relative; z-index: 1; }
        #mplayer { position: absolute; bottom: 10px; }
        #btnwrap { fill: lightblue; cursor: pointer; }
        #btnwrap:hover { fill: lightgreen; }
        #tmsg { fill: tan; stroke: lightblue; stroke-width: 1px; font: bold 1em sans-serif; }
        #lrc { position: absolute; top: 10px; font: bold 2.4em sans-serif; color: transparent; background: linear-gradient(-90deg, tomato, tan) 0 0 / 200% 200%; filter: drop-shadow(2px 2px 4px #000); background-clip: text; -webkit-background-clip: text; text-stroke: 1px lightgreen; -webkit-text-stroke: 1px lightblue; }
        #mpic {position: absolute; left: 0; top: 0; width: 60px;offset-distance: 0;offset-path: path("M0 40 Q500 180, 600 160 T1024 40");animation: move 8s linear infinite;}
        @keyframes bgMove1 { from { background-position: 0 0; } to { background-position: -100% 0; } }
        @keyframes bgMove2 { from { background-position: 0 0; } to { background-position: -100% 0; } }
        @keyframes move { to { offset-distance: 100%;} }
</style>

<div id="papa">
        <img id="mpic" alt="" src="/data/attachment/forum/202209/23/071315t6o896f1t6mtyzbp.gif" />
        <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="4" stroke="rgba(50,120,40,0.75)" />
                </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=1886833453.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 || 5);
                        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-23 07:22

代码:
<style>
        #papa { margin: auto; width: 1024px; height: 640px; background: url('/data/attachment/forum/202209/23/071140hqavv7a5d0vd4viv.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; box-shadow: 3px 3px 20px #000; display: flex; justify-content: center; overflow: hidden; position: relative; z-index: 1; }
        #mplayer { position: absolute; bottom: 10px; }
        #btnwrap { fill: lightblue; cursor: pointer; }
        #btnwrap:hover { fill: lightgreen; }
        #tmsg { fill: tan; stroke: lightblue; stroke-width: 1px; font: bold 1em sans-serif; }
        #lrc { position: absolute; top: 10px; font: bold 2.4em sans-serif; color: transparent; background: linear-gradient(-90deg, tomato, tan) 0 0 / 200% 200%; filter: drop-shadow(2px 2px 4px #000); background-clip: text; -webkit-background-clip: text; text-stroke: 1px lightgreen; -webkit-text-stroke: 1px lightblue; }
        #mpic {position: absolute; left: 0; top: 0; width: 60px;offset-distance: 0;offset-path: path("M0 40 Q500 180, 600 160 T1024 40");animation: move 8s linear infinite;}
        @keyframes bgMove1 { from { background-position: 0 0; } to { background-position: -100% 0; } }
        @keyframes bgMove2 { from { background-position: 0 0; } to { background-position: -100% 0; } }
        @keyframes move { to { offset-distance: 100%;} }
</style>

<div id="papa">
        <img id="mpic" alt="" src="/data/attachment/forum/202209/23/071315t6o896f1t6mtyzbp.gif" />
        <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="4" stroke="rgba(50,120,40,0.75)" />
                </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=1886833453.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 || 5);
                        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-23 07:32

帖子播放器是之前的svg成品,改变些元素颜色,无大变化。

lrc同步歌词样式用HTML+CSS做成,加入了描边属性。昨天已经发过一个这个样式,此帖进一步做相关尝试。

同时检验新版花潮格式的lrc歌词:本帖所用的lrc歌词使用花潮LRC在线增强版制作。增强版将制作、转换与加餐集成于一身,程序将更简洁、更具友好的操作逻辑和更为高效的运行性能。程序测试中,将很快与大家见面。

雄鹰的飞行路线使用svg路径实现,之前也有用过此类路径。

加林森 发表于 2022-9-23 08:23

回来再学习?

起个网名好难 发表于 2022-9-23 09:16

欣赏、学习

换成汉字字体似乎效果差了,如 楷体、宋体、黑体…………, 但微软雅黑和等线还行。

红影 发表于 2022-9-23 10:22

马黑黑 发表于 2022-9-23 07:32
帖子播放器是之前的svg成品,改变些元素颜色,无大变化。

lrc同步歌词样式用HTML+CSS做成,加入了描边属 ...

“增强版将制作、转换与加餐集成于一身,程序将更简洁、更具友好的操作逻辑和更为高效的运行性能。程序测试中,将很快与大家见面。”

这个太好了,热切期待中{:4_199:}{:4_178:}

红影 发表于 2022-9-23 10:24

黑黑又换了播放器按钮,这个歌词颜色设计得漂亮。虽然暂时听不了歌,但觉得画面很和谐{:4_187:}

红影 发表于 2022-9-23 10:28

马黑黑 发表于 2022-9-23 07:32
帖子播放器是之前的svg成品,改变些元素颜色,无大变化。

lrc同步歌词样式用HTML+CSS做成,加入了描边属 ...

雄鹰飞翔的线路挺好的,增加了画面的灵动感。感觉只用Q貌似也能实现这样的效果呢{:4_173:}

梦油 发表于 2022-9-23 11:06

黑黑朋友的制作真大气。

醉美水芙蓉 发表于 2022-9-23 11:34

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

马黑黑 发表于 2022-9-23 12:13

醉美水芙蓉 发表于 2022-9-23 11:37
这个景色真美!

俺的家乡就是美

马黑黑 发表于 2022-9-23 12:16

红影 发表于 2022-9-23 10:28
雄鹰飞翔的线路挺好的,增加了画面的灵动感。感觉只用Q貌似也能实现这样的效果呢

只要是曲线指令都行,看怎么做

马黑黑 发表于 2022-9-23 12:17

红影 发表于 2022-9-23 10:22
“增强版将制作、转换与加餐集成于一身,程序将更简洁、更具友好的操作逻辑和更为高效的运行性能。程序测 ...

一些细节处理还在斟酌中

加林森 发表于 2022-9-23 13:46

我回来啦。这个要好好地研究了。谢谢老黑!{:4_199:}

红影 发表于 2022-9-23 15:47

马黑黑 发表于 2022-9-23 12:16
只要是曲线指令都行,看怎么做

嗯嗯,这个倒是完全看个人喜好呢。

红影 发表于 2022-9-23 15:47

马黑黑 发表于 2022-9-23 12:17
一些细节处理还在斟酌中

黑黑辛苦了{:4_187:}

亚伦影音工作室 发表于 2022-9-23 17:05

老马你歌词转化增强版,有在线吗?

马黑黑 发表于 2022-9-23 18:54

亚伦影音工作室 发表于 2022-9-23 17:05
老马你歌词转化增强版,有在线吗?

会有的

马黑黑 发表于 2022-9-23 18:54

加林森 发表于 2022-9-23 08:23
回来再学习?

学学更健康
页: [1] 2 3 4 5
查看完整版本: 呼伦贝尔