有声有色 发表于 2023-2-24 09:01

评弹——珍珠塔(尤调)

本帖最后由 有声有色 于 2023-2-26 09:06 编辑 <br /><br /><div class="t_fsz">
<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_1840187">
<style>
#papa {
      margin: 120px 0 0 calc(50% - 680px);
      display: grid;
      place-items: center;
      width: 1200px;
      height: 675px;
      background: lightblue url('https://pic.imgdb.cn/item/63f70628f144a010071561db.gif') no-repeat center/cover;
      box-shadow:6px 3px 20px #000;
      user-select: none;
      position: relative;
      z-index: 1;
}
#tit {
      position: absolute;
      width: fit-content;
      height: fit-content;
      right: 5%;
      bottom: 25%;
      color: SkyBlue;
       font: bold 45px/45px 'Microsoft YaHei',serif;

}
.mysp {
      position: relative;
      display: block;
}

@keyframes move {
      0% { right: 10px; transform: rotate(0); color: Yellow; }
      50% { right: 100px; transform: rotate(360deg); color: red; }
      100% { right: 10px; transform: rotate(720deg); color: Snow; }
}

</style>

<div id="papa">
   
</div>
<audio id="aud" src="https://link.hhtjim.com/163/184178.mp3" loop autoplay></audio></div>

<script >
(function() {
      (function(mkPlayer) {let defaults = {lrcAr: [],lrc_css: 'top: 10px; left: 15px;',player_css: '',playerCode: `<style>#mplayer {position: absolute;left: left: calc(50% - 60px);bottom: 210px;--track: hsla(100,30%,80%,.65);--prog: hsla(100,60%,50%,.55);--color: #e9f1f6;}#btnwrap { display: block; fill: var(--color); opacity: .85; cursor: pointer; }#btnwrap:hover { opacity: 1; }#track { fill: none; stroke: var(--track); }#prog { fill: none; stroke: var(--prog); }#tmsg { fill: var(--color); stroke: none; font: bold 1em sans-serif; }#lrc {--motion: cover2;--tt: 1s;--state: running;--bg: linear-gradient(180deg,hsla(100,10%,50%,.75),hsla(100,100%,20%,.65));position: absolute;font: bold 2.4em sans-serif;color: hsl(100, 100%, 90%);white-space: pre;-webkit-background-clip: text;filter: drop-shadow(1px 1px 1px hsla(0, 100%, 0%, .85));z-index: 900;}#lrc::before {position: absolute;content: attr(data-lrc);width: 20%;height: 100%;color: transparent;overflow: hidden;white-space: pre;background: var(--bg);filter: inherit;-webkit-background-clip: text;animation: var(--motion) var(--tt) linear forwards;animation-play-state: var(--state);}@keyframes cover1 { from { width: 0; }to { width: 100%; } }@keyframes cover2 { from { width: 0; }to { width: 100%; } }</style> <svg id="mplayer"width="120" height="120"><g id="circle_wrap" transform="rotate(-90, 60, 60)" style="cursor: pointer;"><circle id="track" cx="60" cy="60" r="50" stroke-width="10" /><circle id="prog" cx="60" cy="60" r="50" stroke-width="10" /></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 id="lrc" data-lrc="HCPlayer">HCPlayer</div>`,};let playCode = (user_config) => {let data = Object.assign({}, defaults, user_config);papa.innerHTML += data.playerCode;mplayer.style.cssText += data.player_css;lrc.style.cssText += data.lrc_css;let mKey = 0, mFlag = true, cc = { x: 1 * track.getAttribute('cx'), y: 1 * track.getAttribute('cy'), len: track.getTotalLength(), };prog.style.strokeDasharray = prog.style.strokeDashoffset = cc.len;btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();circle_wrap.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;};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 < data.lrcAr.length; j++) {if (aud.currentTime >= data.lrcAr) {if (mKey === j) showLrc(data.lrcAr);else continue;}}});aud.addEventListener('pause', () => mState());aud.addEventListener('play', () => mState());aud.addEventListener('seeked', () => calcKey());let mState = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none', lrc.style.setProperty('--state', 'paused')) : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc.style.setProperty('--state', 'running'));let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = data.lrcAr;lrc.dataset.lrc = data.lrcAr.replace(/<br>/, '\n');lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');mKey += 1;mFlag = !mFlag;};let calcKey = () => {for (j = 0; j < data.lrcAr.length; j++) {if (aud.currentTime <= data.lrcAr) {mKey = j - 1;break;}}if (mKey < 0) mKey = 0;if (mKey > data.lrcAr.length - 1) mKey = data.lrcAr.length - 1;let time = data.lrcAr - (aud.currentTime - data.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;};};mkPlayer.HCPlayer = playCode;})(this);
      (function(mkFS) {let setFullScreen = (user_set) => {let pa = user_set.pa;if(typeof(pa) !== 'object') return false;if(!user_set.set) user_set.set = 'color: snow; background: black; border: 2px solid snow; left: 40px; bottom: 40px;';btnMsg = document.createElement('span');btnMsg.style.cssText = `position: absolute; border-radius: 8px; padding: 4px; cursor: pointer; z-index:998; ${user_set.set}`;btnMsg.innerText = '全屏观赏';btnMsg.style.display = 'none';pa.appendChild(btnMsg);let timerId, fs = false;btnMsg.onclick = () => fs ? document.exitFullscreen() : pa.requestFullscreen();pa.addEventListener('mousemove', (e) => {clearTimeout(timerId);btnMsg.style.display = 'block';timerId = setTimeout('btnMsg.style.display = "none"', 3000);});document.addEventListener('fullscreenchange', () => {if (document.fullscreenElement !== null) {fs = true;btnMsg.innerText = '退出全屏';} else {fs = false;btnMsg.innerText = '全屏观赏';}});};mkFS.FS = setFullScreen;})(this);

       let lrcAr = [
                ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
       
];


      HCPlayer({
                lrcAr: lrcAr,
                player_css: 'bottom: 10%; right: 50%;',
                lrc_css: 'left: 120px; top:580px;',
      });

      FS({
                pa: papa,
                set: 'color: snow; background:OliveDrab; border: 2px solid snow;right: 28.5%;bottom: 10%;',
      });

      let spans = [],idx = 0, last = null;

      [...'评弹珍珠塔'].forEach((item,key) => {
                let sp = document.createElement('span');
                sp.className = 'mysp';
                sp.innerHTML = item + '<br>';
                spans.push(sp);
                tit.appendChild(sp);
      });

      let mov = () => {
                if(last != null) spans.style.animation = '';
                spans.style.animation = 'move 2s';
                last = idx;
                idx += 1;
                if(idx >= spans.length) idx = 0;
                setTimeout(mov,2000);
      };

      mov();
})();
</script>
<br><br><br><br><br></td></tr></table>

红影 发表于 2023-2-24 09:17

文字特效用得好。背景图的动态也特别好。欣赏有声有色好帖{:4_187:}

红影 发表于 2023-2-24 09:18

圆环播放器放在人物身上有点不妥,移动到右下的空白处可好?

海笑 发表于 2023-2-24 09:20

欣赏老师佳作!

有声有色 发表于 2023-2-24 09:39

红影 发表于 2023-2-24 09:17
文字特效用得好。背景图的动态也特别好。欣赏有声有色好帖

谢谢一直来的支持

有声有色 发表于 2023-2-24 09:41

红影 发表于 2023-2-24 09:18
圆环播放器放在人物身上有点不妥,移动到右下的空白处可好?

我还不知道怎么移,等会我试试

有声有色 发表于 2023-2-24 09:41

海笑 发表于 2023-2-24 09:20
欣赏老师佳作!

谢谢一直来的支持

有声有色 发表于 2023-2-24 14:27

红影 发表于 2023-2-24 09:17
文字特效用得好。背景图的动态也特别好。欣赏有声有色好帖

吃好午饭,一直在琢磨圆环播放器的代码,到现在也没搞明白<div id="papa">

红影 发表于 2023-2-24 19:18

有声有色 发表于 2023-2-24 09:39
谢谢一直来的支持

客气了,再赏好帖{:4_187:}

红影 发表于 2023-2-24 19:20

有声有色 发表于 2023-2-24 14:27
吃好午饭,一直在琢磨圆环播放器的代码,到现在也没搞明白

在帖子的最后有接口的啊
player_css: 'bottom: 35%; right: 20%;',——这个是播放器的定位
lrc_css: 'left: 120px; top:580px;',——这个是歌词定位

红影 发表于 2023-2-24 19:22

FS({
                pa: papa,
                set: 'color: snow; background:OliveDrab; border: 2px solid snow;right: 22.5%;bottom: 30%;',
      });

这个里面的颜色、定位什么的,是调整那个全屏用的。 都在最后面的接口里。

梦缘 发表于 2023-2-25 09:48

欣赏精彩特效,感谢分享!{:4_187:}

有声有色 发表于 2023-2-26 09:16

红影 发表于 2023-2-24 19:20
在帖子的最后有接口的啊
player_css: 'bottom: 35%; right: 20%;',——这个是播放器的定位
lrc_css:...

谢谢红影老师,我当时调了歌词,上面这一行是调正播放器代码,我以为也是调正歌词的,关键还是不熟悉代码的名字,现在已经改过来了,不好意思回复晚了,昨天去临平路太阳宫,因亲戚家小孩过周岁生日

有声有色 发表于 2023-2-26 09:16

梦缘 发表于 2023-2-25 09:48
欣赏精彩特效,感谢分享!

谢谢支持

红影 发表于 2023-2-26 11:08

有声有色 发表于 2023-2-26 09:16
谢谢红影老师,我当时调了歌词,上面这一行是调正播放器代码,我以为也是调正歌词的,关键还是不熟悉代码 ...

不客气啊,黑黑的封装都有接口的,调整起来特别方便。知道怎么调了,下回做起来也就更方便了{:4_187:}

有声有色 发表于 2023-2-26 14:03

红影 发表于 2023-2-26 11:08
不客气啊,黑黑的封装都有接口的,调整起来特别方便。知道怎么调了,下回做起来也就更方便了

是的 又学到了一招,谢谢

红影 发表于 2023-2-26 21:03

有声有色 发表于 2023-2-26 14:03
是的 又学到了一招,谢谢

不客气啊,我也只是学习中呢{:4_204:}
页: [1]
查看完整版本: 评弹——珍珠塔(尤调)