找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: 武朝歌

请教:同步歌词在编辑器里显示而论坛不显示。谢谢!

[复制链接]

503

主题

2万

回帖

11万

积分

超级版主

积分
117773
发表于 2025-2-14 10:12:35 | 显示全部楼层 IP:亚太地区
武朝歌 发表于 2025-2-14 10:11
我编辑器里显示截图在5#

        你现在再试试看。

208

主题

7573

回帖

4万

积分

版主

积分
44348
 楼主| 发表于 2025-2-14 10:27:58 | 显示全部楼层 IP:
老谟深虑 发表于 2025-2-14 10:04
请问这个代码是在哪里找的?

就是去年保存在文件夹里的一段代码,今天没事翻出来。

208

主题

7573

回帖

4万

积分

版主

积分
44348
 楼主| 发表于 2025-2-14 10:34:32 | 显示全部楼层 IP:

11#难难老师的代码我看不懂,没敢修改。

234

主题

1万

回帖

6万

积分

超级版主

积分
69634
发表于 2025-2-14 10:54:45 | 显示全部楼层 IP:
欣赏武老师精彩制作,画面美,歌曲好听,为您点赞问好!

308

主题

9026

回帖

6万

积分

版主

积分
66073
发表于 2025-2-14 11:23:52 | 显示全部楼层 IP:美国
欣赏老师制作的代码音画,界面很美,歌曲很好听。老师说的问题我也无法解释。有时候编辑器里不正常,到论坛发表是正常的。

45

主题

1374

回帖

9324

积分

镇海神笔

积分
9324
发表于 2025-2-14 11:28:45 | 显示全部楼层 IP:湖北
武朝歌 发表于 2025-2-14 09:45
不好意思,水平有限没看懂。您有空了帮我重写一下吧,谢谢!

就那句有问题啊
  1. <style>
  2.     #papa {
  3.       position: absolute;
  4.       width: 1164px;
  5.       height: 620px;
  6.       background: #000000 url(https://pic.imgdb.cn/item/660bf4919f345e8d0347a514.jpg)no-repeat center/cover;
  7.       overflow: hidden;
  8.       margin-top: 90px;
  9.           left:50%; transform:translate(-50%);
  10.       box-shadow: 0px 0px 0px 2px #ffffff, 0px 0px 0px 8px #880000;
  11.     }

  12.     audio {
  13.       position: absolute;
  14.       top: 580px;
  15.       z-index: 50;
  16.       width: 98%;
  17.       height: 40px;
  18.       outline: none;
  19.       filter: invert(180);
  20.     }

  21.     audio::-webkit-media-controls-enclosure {
  22.       background: transparent;
  23.       border-radius: 4px;
  24.     }

  25.     .media-controls-container,
  26.     .media-controls-container * {
  27.       background: rgb(129, 73, 200); //滤镜反转为 rgba(0, 162, 255, 1);rgba(255, 93, 0, 0.8)  #7eb637 border-radius: 4px;}

  28.       audio::-webkit-media-controls-current-time-display {
  29.         order: 1; //设置弹性盒对象元素的顺序color: #ffffff;text-shadow: unset;}

  30.         audio::-webkit-media-controls-time-remaining-display {
  31.           order: 2;
  32.           color: #000000;
  33.           text-shadow: unset;
  34.         }

  35.         #lrc {
  36.           left: 15%;
  37.           top: 75%;
  38.         }

  39.         #lrcc {
  40.           left: 85%;
  41.           transform: translate(-102%);
  42.           top: 85%;
  43.         }

  44.         #lrc,
  45.         #lrcc {
  46.           --state: paused;
  47.           --motion: cover2;
  48.           --tt: 2s;
  49.           --bg: #880000;
  50.           border: 0px solid black;
  51.           position: absolute;
  52.           z-index: 2;
  53.           font: normal 2.5em 华文隶书;
  54.           color: #000078;
  55.           white-space: pre;
  56.           -webkit-background-clip: text;
  57.           filter: drop-shadow(#FFFFFF 1px 0 0)drop-shadow(#FFFFFF 0 1px 0)drop-shadow(#FFFFFF -1px 0 0) drop-shadow(#FFFFFF 0 -1px 0);
  58.         }

  59.         #lrcc::before,
  60.         #lrc::before {
  61.           position: absolute;
  62.           content: attr(data-lrc);
  63.           width: 20%;
  64.           height: 100%;
  65.           color: transparent;
  66.           overflow: hidden;
  67.           white-space: pre;
  68.           background: var(--bg);
  69.           -webkit-background-clip: text;
  70.           animation: var(--motion) var(--tt) linear forwards;
  71.           animation-play-state: var(--state);
  72.         }

  73.         @keyframes cover1 {
  74.           from {
  75.             width: 0;
  76.           }

  77.           to {
  78.             width: 100%;
  79.           }
  80.         }

  81.         @keyframes cover2 {
  82.           from {
  83.             width: 0;
  84.           }

  85.           to {
  86.             width: 100%;
  87.           }
  88.         }
  89.   </style>
  90.   <div id="papa">
  91.     <div id="testImg">
  92.       <div class='photo'></div>
  93.       <div class='photo'></div>
  94.       <div class='photo'></div>
  95.       <div class='photo'></div>
  96.       <div class='photo'></div>
  97.       <div class='photo'></div>
  98.       <div class='photo'></div>
  99.       <div class='photo'></div>
  100.     </div>
  101.     <audio id="aud" loop controls autoplay>
  102.       <source src="
  103. https://music.163.com/song/media/outer/url?id=460966325.mp3" />
  104.     </audio>
  105.     <div id="lrc" data-lrc=""></div>
  106.     <div id="lrcc" data-lrc=""></div>
  107.   </div><div style="height:960px;"></div>
  108.   <span id="lrcStr" style="visibility: hidden;"> [00:00.00] 武朝歌欢迎您
  109. [00:15.00] 《芦花》
  110. [00:22.33]芦花白 芦花美
  111. [00:28.23]花絮满天飞
  112. [00:33.68]千思万缕意绵绵
  113. [00:39.46]路上彩云追
  114. [00:44.86]追过山 追过水
  115. [00:50.77]花飞为了谁
  116. [00:56.31]大雁成行人双对
  117. [01:02.02]相思花为媒
  118. [01:07.77]情和爱 花为媒
  119. [01:13.72]千里万里梦相随
  120. [01:19.42]莫忘故乡秋光好
  121. [01:24.66]早戴红花报春回
  122. [01:30.48]情和爱 花为媒
  123. [01:36.16]千里万里梦相随
  124. [01:41.88]莫忘故乡秋光好
  125. [01:47.37]早戴红花报春回
  126. [01:53.91]
  127. [02:03.82]芦花白 芦花美
  128. [02:10.00]花絮满天飞
  129. [02:15.30]千思万缕意绵绵
  130. [02:21.09]路上彩云追
  131. [02:26.68]追过山 追过水
  132. [02:32.58]花飞为了谁
  133. [02:38.02]大雁成行人双对
  134. [02:43.81]相思花为媒
  135. [02:49.52]情和爱 花为媒
  136. [02:55.23]千里万里梦相随
  137. [03:00.76]莫忘故乡秋光好
  138. [03:06.12]早戴红花报春回
  139. [03:12.13]情和爱 花为媒
  140. [03:18.05]千里万里梦相随
  141. [03:23.76]莫忘故乡秋光好
  142. [03:29.16]早戴红花报春回
  143. [03:34.92]莫忘故乡秋光好
  144. [03:40.46]早戴红花报春回
  145. [04:00.04]</span>
  146.   <script>
  147.     (function() {
  148.         /*变量 :mKey - 当前歌词索引;averAdd :平均值补偿*/
  149.         let mKey = 0,
  150.           averAdd = 0.3;
  151.         let lrcTime = (ar) => {
  152.           let tmpAr = [];
  153.           for (j = 0; j < ar.length - 1; j++) {
  154.             if (j !== ar.length - 1) tmpAr[j] = parseFloat((ar[j + 1][0] - ar[j][0]).toFixed(1));
  155.           }
  156.           let aver = parseInt(tmpAr.reduce((a, b) => a + b) / (tmpAr.length - 1)) + averAdd;
  157.           tmpAr.push(aver);
  158.           tmpAr.forEach((item, key) => {
  159.             ar[key][2] = item > aver ? aver : item;
  160.           });
  161.           return ar;
  162.         };
  163.         let getLrcAr = (text) => {
  164.           let lrcAr = [];
  165.           let arr = "";
  166.           let calcRule = [60, 1, 0.001];
  167.           for (x of text.split('\n')) {
  168.             let ar = [];
  169.             let re = /\d+[\.:]\d+([\.:]\d+)?/g;
  170.             let geci = x.replace(re, '');
  171.             if (geci) {
  172.               geci = geci.replace(/[\[\]\'"\t,]s?/g, '');
  173.               let time = x.match(re);
  174.               if (time != null) {
  175.                 for (y of time) {
  176.                   let tmp = y.match(/\d+/g);
  177.                   let sec = 0;
  178.                   for (z in tmp) sec += tmp[z] * calcRule[z];
  179.                   ar[0] = [parseFloat(sec.toFixed(2)), geci];
  180.                   lrcAr.push(ar[0]);
  181.                 }
  182.               }
  183.             }
  184.           }
  185.           lrcAr.sort((a, b) => a[0] - b[0]);
  186.           return (lrcTime(lrcAr));
  187.         };
  188.         let showLrc = (time) => {
  189.           lrca = lrcAr[mKey][1];
  190.           lrcAr.length == mKey + 1 ? lrcb = "" : lrcb = lrcAr[mKey + 1][1]; //判断最后一句歌词
  191.           let Y = String(mKey / 2).indexOf(".");
  192.           if (Y == -1) {
  193.             0 == mKey && (lrc.innerHTML = lrca);
  194.             lrc.dataset.lrc = lrca;
  195.             lrcc.innerHTML = lrcb;
  196.             lrcc.dataset.lrc = "";
  197.             lrc.style.setProperty('--motion', 'cover1');
  198.             lrc.style.setProperty('--tt', time + 's');
  199.             lrc.style.setProperty('--state', 'running');
  200.             lrcc.style.setProperty('--motion', 'cover2');
  201.           } else {
  202.             lrc.innerHTML = lrcb;
  203.             lrcc.dataset.lrc = lrca;
  204.             lrc.dataset.lrc = "";
  205.             lrcc.style.setProperty('--motion', 'cover1');
  206.             lrcc.style.setProperty('--tt', time + 's');
  207.             lrcc.style.setProperty('--state', 'running');
  208.             lrc.style.setProperty('--motion', 'cover2');
  209.           }
  210.           mKey += 1;
  211.         };
  212.         let calcKey = () => {
  213.           for (j = 0; j < lrcAr.length; j++) {
  214.             if (aud.currentTime <= lrcAr[j][0]) {
  215.               mKey = j - 1;
  216.               break;
  217.             }
  218.           }
  219.           if (mKey < 0) mKey = 0;
  220.           if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;
  221.           let time = lrcAr[mKey][2] - (aud.currentTime - lrcAr[mKey][0]);
  222.           showLrc(time);
  223.         };
  224.         let mState = () => aud.paused ? (lrc.style.setProperty("--state", "paused"), lrcc.style.setProperty("--state", "paused")) : (lrc.style.setProperty("--state", "running"), lrcc.style.setProperty("--state", "running"));
  225.       /*监听播放进度*/
  226.       aud.addEventListener('timeupdate', () => {
  227.         for (j = 0; j < lrcAr.length; j++) {
  228.           if (aud.currentTime >= lrcAr[j][0]) {
  229.             cKey = j;
  230.             if (mKey === j) showLrc(lrcAr[j][2]);
  231.             else continue;
  232.           }
  233.         }
  234.       }); aud.addEventListener('pause', () => mState()); /*监听暂停事件*/ aud.addEventListener('play', () => mState()); /*监听播放事件*/ aud.addEventListener('seeked', () => calcKey()); /*监听查询事件*/
  235.       let lrcAr = getLrcAr(lrcStr.innerHTML); /*获得歌词数组*/
  236.     })();
  237.     (function() {
  238.       var image = document.getElementById("testImg");
  239.       let mState = () => aud.paused ? image.classList.add('stop') : image.classList.remove('stop');
  240.       aud.addEventListener('play', () => mState());
  241.       aud.addEventListener('pause', () => mState());
  242.     })();
  243.   </script>
  244.   <style type="text/css">
  245.     .photo {
  246.       width: 100%;
  247.       height: 100%;
  248.       box-shadow: 0px 0px 0px 2px #ffffff;
  249.       position: absolute;
  250.       z-index: -2;
  251.       top: 0px;
  252.       left: 0px;
  253.       opacity: 0;
  254.       animation: round 48s linear infinite;
  255.     }

  256.     @keyframes round {
  257.       0% {
  258.         opacity: 1;
  259.         clip-path: ellipse(0% 0% at 50% 50%);
  260.       }

  261.       2% {
  262.         opacity: 1;
  263.         clip-path: ellipse(1% 1% at 50% 50%);
  264.       }

  265.       9% {
  266.         opacity: 1;
  267.         clip-path: ellipse(50% 50% at 50% 50%);
  268.       }

  269.       12% {
  270.         clip-path: ellipse(100% 100% at 50% 50%);
  271.         opacity: 1;
  272.       }

  273.       16% {
  274.         clip-path: ellipse(100% 100% at 50% 50%);
  275.         -webkit-transform: translate(0%, 0%)scale(1);
  276.         opacity: 0;
  277.       }
  278.     }

  279.     .photo:nth-child(1) {
  280.       background: url(https://pic.imgdb.cn/item/660bf4919f345e8d0347a382.jpg
  281. )no-repeat center/cover;
  282.       animation-delay: 42s;
  283.     }

  284.     .photo:nth-child(2) {
  285.       background: url(https://pic.imgdb.cn/item/660bf4919f345e8d0347a514.jpg                                                         
  286. )no-repeat center/cover;
  287.       animation-delay: 36s;
  288.     }

  289.     .photo:nth-child(3) {
  290.       background:
  291.         url(https://pic.imgdb.cn/item/660bf4919f345e8d0347a0ee.jpg
  292. )no-repeat center/cover;
  293.       animation-delay: 30s;
  294.     }

  295.     .photo:nth-child(4) {
  296.       background:
  297.         url(https://pic.imgdb.cn/item/660bf48e9f345e8d03478d6e.jpg
  298. )no-repeat center/cover;
  299.       animation-delay: 24s;
  300.     }

  301.     .photo:nth-child(5) {
  302.       background:
  303.         url(https://pic.imgdb.cn/item/660bf48e9f345e8d03478ba1.jpg
  304. )no-repeat center/cover;
  305.       animation-delay: 18s;
  306.     }

  307.     .photo:nth-child(6) {
  308.       background:
  309.         url(https://pic.imgdb.cn/item/660bf4919f345e8d0347a514.jpg
  310. )no-repeat center/cover;
  311.       animation-delay: 12s;
  312.     }

  313.     .photo:nth-child(7) {
  314.       background:
  315.         url(https://pic.imgdb.cn/item/660bf4919f345e8d0347a382.jpg
  316. )no-repeat center/cover;
  317.       animation-delay: 6s;
  318.     }

  319.     .photo:nth-child(8) {
  320.       background:
  321.         url(hhttps://pic.imgdb.cn/item/660bf4919f345e8d0347a382.jpg
  322. )no-repeat center/cover;
  323.       animation-delay: 0s;
  324.     }

  325.     .stop .photo:nth-child(1),
  326.     .stop .photo:nth-child(2),
  327.     .stop .photo:nth-child(3),
  328.     .stop .photo:nth-child(4),
  329.     .stop .photo:nth-child(5),
  330.     .stop .photo:nth-child(6),
  331.     .stop .photo:nth-child(7),
  332.     .stop .photo:nth-child(8) {
  333.       animation-play-state: paused;
  334.     }
  335.   </style>
复制代码

45

主题

1374

回帖

9324

积分

镇海神笔

积分
9324
发表于 2025-2-14 11:42:25 | 显示全部楼层 IP:湖北
武朝歌 发表于 2025-2-14 09:45
不好意思,水平有限没看懂。您有空了帮我重写一下吧,谢谢!

回复了,等待审核中…………

45

主题

1374

回帖

9324

积分

镇海神笔

积分
9324
发表于 2025-2-14 11:44:21 | 显示全部楼层 IP:湖北
老谟深虑 发表于 2025-2-14 10:04
请问这个代码是在哪里找的?

亚伦的

503

主题

2万

回帖

11万

积分

超级版主

积分
117773
发表于 2025-2-14 12:14:55 | 显示全部楼层 IP:亚太地区
武朝歌 发表于 2025-2-14 10:34
11#难难老师的代码我看不懂,没敢修改。

         我也不懂,不用修改了,就当没有同步歌词。

503

主题

2万

回帖

11万

积分

超级版主

积分
117773
发表于 2025-2-14 12:16:11 | 显示全部楼层 IP:亚太地区

       是亚伦的,我想找到这个源代码。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|离退休论坛 ( 浙B2-20100176 )

GMT+8, 2025-7-14 12:15 , Processed in 0.132726 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表