找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: 丁香

看图听歌乐幽幽

[复制链接]

286

主题

9096

回帖

7万

积分

版主

积分
70582
 楼主| 发表于 6 天前 | 显示全部楼层 IP:澳大利亚
[i=s] 本帖最后由 丁香 于 2025-9-12 14:52 编辑 [/i]

全屏欣赏








286

主题

9096

回帖

7万

积分

版主

积分
70582
 楼主| 发表于 6 天前 | 显示全部楼层 IP:澳大利亚
本帖最后由 丁香 于 2025-9-9 17:10 编辑
  1. <style>
  2.   #oBlk {
  3.     margin-left: 50% ; left: -598px;
  4.     margin-top:110px;
  5.     width: 1210px;
  6.     height: 640px;
  7.     box-shadow: 3px 3px 10px #000;
  8.     overflow: hidden;
  9.     position: absolute;
  10.   }

  11.   #oBlk::before,
  12.   #oBlk::after {
  13.     position: absolute;
  14.     content: '';
  15.     left: var(--curX0);
  16.     top: 0px;
  17.     width: 100%;
  18.     height: 100%;
  19.     background: url('https://file.uhsea.com/2411/ab9117a7ff4f164d10e606aca6a0bf51GE.jpg') no-repeat center / cover;
  20.   }

  21.   #oBlk::after {
  22.     left: var(--curX1);
  23.     transform: scaleX(-1);
  24.   }
  25. </style>
  26. <div id="oBlk"></div>
  27. <div style="height:640px;"></div>
  28. <script>
  29. {
  30.   let blkWidth = oBlk.offsetWidth;
  31.   let step = 1.0, tune = 0,
  32.     curX0 = 0,
  33.     curX1 = blkWidth,
  34.     raf;

  35.   let moving = () =>        {
  36. /*   
  37.         //自左向右
  38.     curX0 += step;
  39.     curX1 += step;
  40.     if(curX0 >= blkWidth) curX0 = -blkWidth;
  41.     if(curX1 >= blkWidth) curX1 = -blkWidth;
  42. */        
  43.         //自右向左
  44.     curX0 -= step;
  45.     curX1 -= step;
  46.     if(curX0 <= -blkWidth) curX0 = blkWidth;
  47.     if(curX1 <= -blkWidth) curX1 = blkWidth;

  48.     tune = curX1 + (curX0 >= 0 ? 1 : -1);
  49.     oBlk.style.setProperty('--curX0', curX0 + 'px');
  50.     oBlk.style.setProperty('--curX1', tune + 'px');
  51.     raf = requestAnimationFrame(moving);
  52.   };
  53.   moving();
  54. }  
  55. </script></div></div><br><br><br><br><br><video autoplay="" controls="" height="1" src="https://link.hhtjim.com/kw/405903864.mp3" width="2">
复制代码

496

主题

4万

回帖

15万

积分

版主

积分
158843
发表于 6 天前 来自手机 | 显示全部楼层 IP:山东
丁香 发表于 2025-9-7 14:20
谢谢你的支持鼓励,下午好!

为你点赞

687

主题

3万

回帖

14万

积分

版主

积分
144838
发表于 6 天前 | 显示全部楼层 IP:河北石家庄
丁香 发表于 2025-9-7 14:20
本帖最后由 丁香 于 2025-9-7 17:47 编辑

丁香,请你把21楼的这个视频的代码,发给我,好吗。

286

主题

9096

回帖

7万

积分

版主

积分
70582
 楼主| 发表于 昨天 14:53 | 显示全部楼层 IP:澳大利亚
微尘 发表于 2025-9-7 19:48
丁香,请你把21楼的这个视频的代码,发给我,好吗。
  1. <div style="position: absolute; left:20px;width:100%;margin-top:-20px;">
  2. <style>
  3. #papa { margin: 150px 0 20px calc(50% - 621px); background:#800 url(' ')no-repeat center/cover;width: 1164px; height: 700px;   box-shadow: 3px 3px 6px gray; overflow: hidden; z-index: 1; position: relative; display: grid; place-items: center; }

  4. #mdiv {z-index: 10;
  5.         --size: 0px;
  6.         --color: teal;
  7.         position: relative;
  8.         left: calc(-35% - var(--size) / 2);
  9.         top: 230px;
  10.         width: var(--size);
  11.         height: var(--size);
  12.         display: grid;
  13.         place-items: center;
  14.         animation: rot 8s linear infinite ;
  15.         cursor: pointer;
  16. }
  17. #mdiv::before, #mdiv::after {
  18.         position: absolute;
  19.         content: '';
  20.         width: 0;
  21.         height: 0;
  22.         border-style: solid;
  23.         border-width: calc(var(--size) / 2) calc(var(--size) / 2 - 35px);
  24.         border-color: var(--color) transparent;
  25.        
  26.         border-radius: 100% 100% 100% 100%;
  27.         filter:drop-shadow(#000 1px 0 0)drop-shadow(#000 0 1px 0)drop-shadow(#000 -1px 0 0) drop-shadow(#000 0 -1px  0);
  28. }
  29. #mdiv::after { transform: rotate(90deg) }
  30. @keyframes rot { 100% { transform: rotate(360deg);filter:hue-rotate(360deg); } }

  31. #vid {z-index: 2;
  32.         position: absolute;
  33.         width: 100%;
  34.         height: 100%;
  35.         object-fit: cover;
  36.         -webkit-mask-image: radial-gra**nt(black 10% ,transparent 90%);
  37. }
  38. #vido {z-index: 1;
  39.         position: absolute;
  40.         width: 100%;
  41.         height: 100%;
  42.         object-fit: cover;
  43.         }

  44. #fullscreen { position: absolute; top: 30px; right:30px;font: normal 2em/0em 楷体;color:#000; opacity: 1; cursor: pointer; z-index: 111}
  45. </style>
  46. <div id="papa">
  47. <div id="mdiv" title=""></div>
  48. <div data-lrc=" " id="lrc" title="歌词显示"> </div>   
  49. <span id="fullscreen">全屏欣赏</span>
  50. <audio id="aud" src="https://link.hhtjim.com/163/26599625.mp3" autoplay loop></audio>   
  51. <video id="vid" src=" " autoplay loop muted></video>
  52. <video id="vido" src="
  53. https://alimov2.a.kwimgs.com/upic/2025/09/06/10/BMjAyNTA5MDYxMDQ4NDFfNDYzNDgzODgwOF8xNzQzMTY0MTM1NDlfMl8z_b_B781fa40e9a5090232b29b71cf1dba1ec.mp4
  54. " autoplay loop muted></video>
  55. </div>


  56.    
  57. <script>
  58. mdiv.onclick = () => aud.paused ?( aud.play(),vid.play(),vido.play()):(aud.pause(),vid.pause(),vido.pause());
  59. mdiv.style.animationPlayState = aud.paused ? 'paused' : 'running';
  60. aud.addEventListener('playing', () =>mdiv.style.animationPlayState = 'running');
  61. aud.addEventListener('pause', () =>mdiv.style.animationPlayState = 'paused');

  62. let fs = true;
  63.         fullscreen.onclick = () => {
  64.                 fs ? (fullscreen.innerText = '退出全屏', papa.requestFullscreen()) : (fullscreen.innerText = '全屏欣赏', document.exitFullscreen());
  65.                 fs = !fs;
  66.         };

  67. </script>
  68. <style type="text/css">
  69. #lrc {--state: paused;--motion: cover2;--tt: 2s;--bg: linear-gra**nt(0deg, #880000, #880000, #880000);
  70. position: absolute;z-index: 6;left: 50%; top: 85%;transform: translate(-50%);font:normal 3em 华文新魏; font-weight:400;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 -1px  0);}
  71. #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);}
  72. @keyframes cover1{ to { clip-path: inset(0 0 0 0); } }@keyframes cover2 { to { clip-path: inset(0 0 0 0); } }
  73. </style>
  74. <script >
  75. (function() {
  76. /*原始lrc歌词*/
  77. let lrcStr = `[00:00.00]    爱上草原爱上你:琪琪格



  78. [00:11.50]LRC歌词:竹海人家

  79. [00:23.57]那是谁的画笔 蘸满了绿色

  80. [00:27.89]那是谁的心动 像盛开的花朵

  81. [00:32.12]你的大眼睛 藏着一首歌

  82. [00:36.34]听醉了一弯溪水听醉了我

  83. [00:40.60]那是谁的浪漫 蓝的像童话

  84. [00:44.68]那是谁的笑声 洗白了云朵

  85. [00:48.82]我的幸福就像花儿一样

  86. [00:53.12]一夜被风撒遍满山满坡

  87. [00:57.36]爱上草原爱上你

  88. [01:01.48]爱上这晴朗的好天气

  89. [01:05.81]爱上你的诗情和画意

  90. [01:09.93]爱上这份纯净清澈见底

  91. [01:14.23]爱上草原爱上你

  92. [01:18.32]爱上这简单让我着迷

  93. [01:22.52]爱上爱你这真实的感觉

  94. [01:26.70]让我走进你的梦里 和你在一起

  95. [01:33.34] 让风儿吹来花开的消息

  96. [01:35.51]让月儿知道我在等着你

  97. [01:37.64]总以为惯疲倦和拥挤

  98. [01:39.89]一路奔跑让我忘记自己

  99. [01:41.60]爱上草原爱上你

  100. [01:45.75]

  101. [01:49.75]那是谁的画笔 蘸满了绿色

  102. [01:54.08]那是谁的心动 像盛开的花朵

  103. [01:58.32]你的大眼睛 藏着一首歌

  104. [02:02.52]听醉了一弯溪水听醉了我

  105. [02:06.75]那是谁的浪漫 蓝的像童话

  106. [02:10.95]那是谁的笑声 洗白了云朵

  107. [02:15.12]我的幸福就像花儿一样

  108. [02:19.41]一夜被风撒遍满山满坡

  109. [02:23.58]爱上草原爱上你

  110. [02:27.82]爱上这晴朗的好天气

  111. [02:31.97]爱上你的诗情和画意

  112. [02:36.17]爱上这份纯净清澈见底

  113. [02:40.40]爱上草原爱上你

  114. [02:44.71]爱上这简单让我着迷

  115. [02:48.74]爱上爱你这真实的感觉

  116. [02:53.04]让我走进你的梦里 和你在一起

  117. [02:59.13]爱上草原爱上你

  118. [03:03.39]爱上这晴朗的好天气

  119. [03:07.67]爱上你的诗情和画意

  120. [03:11.81]爱上这份纯净清澈见底

  121. [03:16.16]爱上草原爱上你

  122. [03:20.28]爱上这简单让我着迷

  123. [03:24.58]爱上爱你这真实的感觉

  124. [03:28.69]让我走进你的梦里 和你在一起



  125. `;
  126. /*变量 :mKey - 当前歌词索引;mFlag :调用关键帧动画索引;averAdd :平均值补偿*/
  127. let mKey = 0, mFlag = true, averAdd = 0.3;
  128. /*函数 :获取每句歌词用时,歌词用时若超过平均值则取平均值,最后一句歌词则取平均值*/
  129. let lrcTime = (ar) => { let tmpAr = [];
  130. for(j = 0; j <ar.length - 1; j ++) { if(j !== ar.length - 1) tmpAr[j] = parseFloat((ar[j+1][0] - ar[j][0]).toFixed(1));}
  131. let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
  132. tmpAr.push(aver);
  133. tmpAr.forEach((item,key) => {ar[key][2] = item > aver ? aver : item; });
  134. return ar;};
  135. /*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
  136. let getLrcAr = (text) => {
  137.        let lrcAr = [];
  138.         let calcRule = [60,1,0.001];
  139.        for(x of text.split('\n')) {
  140.               let ar = [];
  141.                let re = /\d+[\.:]\d+([\.:]\d+)?/g;
  142.                let geci = x.replace(re,'');
  143.                if(geci) {
  144.                        geci = geci.replace(/[\[\]\'"\t,]s?/g,'');
  145.                         let time = x.match(re);
  146.                        if(time != null) {
  147.                                for(y of time) {
  148.                                         let tmp = y.match(/\d+/g);
  149.                                        let sec = 0;
  150.                                        for(z in tmp) sec += tmp[z] * calcRule[z];
  151.                                        ar[0] = [parseFloat(sec.toFixed(2)), geci];
  152.                                        lrcAr.push(ar[0]);
  153.                                 }
  154.                        }
  155.                 }
  156.         }
  157.         lrcAr.sort((a,b)=> a[0] - b[0]);
  158.         return(lrcTime(lrcAr));
  159. };
  160. /*函数 :模拟显示同步歌词*/
  161. let showLrc = (time) => {
  162.         let name = mFlag ? 'cover1' : 'cover2';
  163.        lrc.innerHTML = lrcAr[mKey][1];
  164.         lrc.dataset.lrc = lrcAr[mKey][1];
  165.         lrc.style.setProperty('--motion', name);
  166.         lrc.style.setProperty('--tt', time + 's');
  167.         lrc.style.setProperty('--state', 'running');
  168.         mKey += 1;
  169.        mFlag = !mFlag;
  170. };
  171. /*函数 :处理当前歌词索引 mKey*/
  172. let calcKey = () => {
  173.         for (j = 0; j < lrcAr.length; j++) {
  174.                 if (aud.currentTime <= lrcAr[j][0]) {
  175.                         mKey = j - 1;
  176.                         break;
  177.                }
  178.       }
  179.        if (mKey < 0) mKey = 0;
  180.         if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;
  181.        let time = lrcAr[mKey][2] - (aud.currentTime - lrcAr[mKey][0]);
  182.         showLrc(time);
  183. };
  184. /*格式化时间信息*/
  185. let toMin = (val) => {
  186.       if (!val) return '00:00';
  187.       val = Math.floor(val);
  188.        let min = parseInt(val / 60),
  189.         sec = parseFloat(val % 60);
  190.        if (min < 10) min = '0' + min;
  191.         if (sec < 10) sec = '0' + sec;
  192.         return min + ':' + sec;
  193. }
  194. /*函数 :关键帧动画状态切换*/
  195. let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),mdiv.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),mdiv.style.animationPlayState = 'running');
  196. /*监听播放进度*/
  197. aud.addEventListener('timeupdate', () => {
  198.         for (j = 0; j < lrcAr.length; j++) {
  199.                 if (aud.currentTime >= lrcAr[j][0]) {
  200.                         cKey = j;
  201.                         if (mKey === j) showLrc(lrcAr[j][2]);
  202.          else continue;
  203.        }
  204.     }
  205. });
  206. aud.addEventListener('pause', () => mState());/*监听暂停事件*/
  207. aud.addEventListener('play', () => mState());/*监听播放事件*/
  208. aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
  209. let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
  210. })();
  211. </script>
  212. </div>
  213. <div style="height:660px;"></div>

  214. <br /><br /><br /><br /><br /><br /><br /><br />
  215. </td></tr>
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-9-13 19:32 , Processed in 0.057202 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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