找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: 老谟深虑

学习亚伦老师代码《歌曲:我爱你勐巴拉娜西》

[复制链接]

498

主题

2万

回帖

11万

积分

超级版主

积分
116893
 楼主| 发表于 2025-2-15 12:18:01 | 显示全部楼层 IP:亚太地区
咕咚来了 发表于 2025-2-15 12:03
看到我截图的那些代码了吧,好像代码不对……

       代码都是亚伦老师的源代码,我是用他的源代码制作的。到咱论坛就的修改代码,才能正常。咱不会修改呀。

498

主题

2万

回帖

11万

积分

超级版主

积分
116893
 楼主| 发表于 2025-2-15 12:22:17 | 显示全部楼层 IP:亚太地区
咕咚来了 发表于 2025-2-15 12:03
看到我截图的那些代码了吧,好像代码不对……
  1. <br /><br /><style type="text/css">
  2. #papa { margin: 140px 0 20px calc(50% - 621px); background:url('') no-repeat center/cover;width: 1200px; height: 700px;   box-shadow: 3px 3px 6px gray; overflow: hidden; z-index: 1; position: relative; display: grid; place-items: center; }

  3. #bjbs{animation: rotating 1s linear infinite;width: 1200px; height: 700px;position: absolute;background:url('https://cccimg.com/view.php/2d3863701fe582cb565664e92423ae92.jpg')no-repeat center/cover;}
  4. @keyframes rotating{50%{filter:hue-rotate(360deg)contrast(110%)brightness(100%);}}

  5. #mplayer {z-index: 8;
  6.         position: absolute;
  7.         left:90px;
  8.         bottom: 20px;
  9.         width: 40px;
  10.         height: 40px;
  11. opacity: 1;
  12.         transition: .2s;
  13.        
  14.         place-items: center;
  15.         --disp1: 0; --disp2: 1;
  16. }
  17. #mplayer::before , #mplayer::after{
  18.         position: absolute;
  19.         content: '';
  20. cursor: pointer;
  21.         transition: .2s;
  22. }
  23. #mplayer::before {
  24.         width: 40px;
  25.         height: 40px;opacity: 1;
  26.         background: url("https://pic.imgdb.cn/item/666469465e6d1bfa05bd07ea.png") no-repeat center/cover;
  27.         opacity: var(--disp1);
  28. }
  29. #mplayer::after {
  30.         width: 40px;
  31.         height: 40px;opacity: 1;
  32.         background: url("https://pic.imgdb.cn/item/6664693a5e6d1bfa05bcf7d3.png")no-repeat center/cover;
  33.         opacity: var(--disp2);
  34. }

  35. #tmsg {position: absolute;z-index: 8;
  36.         font: normal 12px sans-serif;
  37.         color: #ffffff;
  38.          bottom: 30px;
  39.         left:87%;}
  40. #prog {position: absolute;z-index: 8;
  41.         width: 70%;
  42.         height: 1.5px;
  43.         cursor: pointer;
  44.          bottom: 35px;
  45. left:16%;
  46. border-radius: 1px;}

  47. #bt_prev{position: absolute;z-index: 8;
  48.         width:30px;
  49.         height: 30px;
  50. bottom: 24px;left:40px;
  51.         background: url("https://pic.imgdb.cn/item/6664695c5e6d1bfa05bd23cb.png")no-repeat center/cover;}
  52. #bt_pnev{position: absolute;z-index: 8;
  53.         width:30px;
  54.         height: 30px;
  55. bottom: 24px;left:150px;
  56.         background: url("https://pic.imgdb.cn/item/66651ae45e6d1bfa0552bf2a.png")no-repeat center/cover;}
  57. #lb{ position: absolute; bottom: 30px;right:52px; width: 22px; height: 20px;z-index: 8; }
  58. #lb img{ width: 100%; height: 100%;  }

  59. .first{
  60.   left:100px;background:url("https://cccimg.com/view.php/c349538ab1e54e665470288cc0cfea2f.jpg")no-repeat center/cover;
  61.    animation: breath  3s  infinite  linear;
  62. }
  63. .second{
  64.   left:300px;background:url("https://cccimg.com/view.php/2a821671bfad68b2a7874d62670638ef.jpg")no-repeat center/cover;
  65.    animation: breath  3s  0.25s infinite  linear;
  66. }
  67. .third{
  68.   left:500px;background:url("https://cccimg.com/view.php/768e147464e634d6a1305de40e6f9e4b.jpg")no-repeat center/cover;
  69.    animation: breath  3s 0.5s infinite  linear;
  70. }
  71. .forth{
  72.   left:700px;background:url("https://cccimg.com/view.php/0c398f295f933b023a41b1ee0ab02ccf.jpg")no-repeat center/cover;
  73.   animation: breath  3s 0.75s infinite  linear;
  74. }
  75. .morex{
  76.   left:900px;background:url("https://cccimg.com/view.php/519a8dcb28b452ad53c1c8a866746d6f.jpg")no-repeat center/cover;
  77.   animation: breath  3s 1s infinite  linear;
  78. }

  79. .stop .first,
  80. .stop .second,
  81. .stop .third,
  82. .stop .forth,  
  83. .stop .morex{animation-play-state: paused;}
  84. .ball{
  85.   position:absolute;
  86.   top:0;
  87.   bottom:0;  border-radius: 4px;
  88.   margin:auto; box-shadow: 0px 0px 0px 4px #800000 inset,0px 0px 0px 5px #fff inset;
  89.   width:140px;
  90.   height:250px;
  91. }

  92. @keyframes breath{
  93.   0%{
  94.      transform:scale(0.6);
  95.    
  96.     opacity:1;transform-timing-function:linear;
  97.    
  98.   }
  99.   25%{
  100.      transform:scale(0.8);
  101.    
  102.     opacity:1;
  103.     transform-timing-function:linear;
  104.   }
  105.   50%{
  106.      transform:scale(1);
  107.    
  108.     opacity:1;
  109.     transform-timing-function:linear;
  110.   }
  111.   75%{
  112.      transform:scale(1.2);

  113.     opacity:1;
  114.     transform-timing-function:ease-out;
  115.   }
  116.   100%{
  117.      transform:scale(1.4);
  118.   
  119.     opacity:.4;
  120.     transform-timing-function:ease-out;
  121.   }
  122. }


  123. .cont {position: absolute;z-index: 2;
  124.   width: 0;
  125.   height: 0;

  126.   top: 20%;
  127.   left: 40%;
  128.   perspective: 420px;
  129.   perspective-origin: center -150px;
  130. }

  131. .bird {
  132.   width: 0;
  133.   height: 30px;
  134.   position: absolute;
  135.   top: 50%;
  136.   left: 50%;
  137.   animation: bird 15s infinite linear;
  138. }

  139. .bird:nth-child(2) {
  140.   animation-delay: -5s;
  141. }
  142. .bird:nth-child(3) {
  143.   animation-delay: -10s;
  144. }
  145. .stop .bird::before,
  146. .stop .bird::after{animation-play-state: paused;}
  147. .stop .bird,
  148. .stop .bird:nth-child(2),
  149. .stop .bird:nth-child(3){animation-play-state: paused;}

  150. @keyframes bird {
  151.   from {
  152.     transform: translate(-50%, -50%) rotateY(0deg) translate3d(150px, 0, 0);
  153.   }
  154.   to {
  155.     transform: translate(-50%, -50%) rotateY(-360deg) translate3d(150px, 0, 0);
  156.   }
  157. }
  158. .bird::before, .bird::after {
  159.   content: "";
  160.   width: 50px;
  161.   height: 30px;
  162.   position: absolute;
  163.   top: 0;
  164.   border: 0 solid;
  165.   border-top: 5px solid #aaa;
  166.   animation: 1s infinite ease-in-out;
  167. }
  168. .bird::before {
  169.   right: -3px;
  170.   animation-name: wing-b;
  171. }
  172. @keyframes wing-b {
  173.   0%, 100% {
  174.     border-radius: 10% 100%;
  175.   }
  176.   33% {
  177.     border-radius: 50% 100%;
  178.   }
  179. }
  180. .bird::after {
  181.   left: -3px;
  182.   animation-name: wing-a;
  183. }
  184. @keyframes wing-a {
  185.   0%, 100% {
  186.     border-radius: 100% 10%;
  187.   }
  188.   33% {
  189.     border-radius: 100% 50%;
  190.   }
  191. }

  192. </style>



  193. <div id="papa">
  194. <div id="bjbs"> </div>
  195. <div id="tnpmImg">
  196. <div class="cont"  >
  197. <div class="bird"></div>
  198.   <div class="bird"></div>
  199.   <div class="bird"></div>
  200. </div>
  201. </div>
  202. <div id="testImg">
  203. <div class="ball first"></div>
  204. <div class="ball second"></div>
  205. <div class="ball third"></div>
  206. <div class="ball forth"></div>
  207. <div class="ball morex"></div>
  208. </div>
  209. <div id="tmsg">00:00 | 00:00</div>

  210. <div id="prog" title="播放进度条"></div>

  211. <div id="bt_prev" title="无效"></div>

  212. <div id="bt_pnev" title="无效"></div>

  213. <div id="lb" title="喇叭"><img alt="" id="lbImg" src="https://pic.imgdb.cn/item/662615500ea9cb14035d435e.gif" /></div>

  214. <div id="mplayer" title="暂停/播放"></div>

  215. <div data-lrc="亚伦影音工作室" id="lrc">亚伦影音工作室</div>
  216. </div>
  217. <audio autoplay="" id="aud" loop="" src="https://cccimg.com/view.php/5960de26e84caf023b6d9d65324a95b5.mp3">&nbsp;</audio>

  218. <style type="text/css">#lrc {
  219.         --state: paused;
  220.         --motion: cover2;
  221.         --tt: 2s;
  222.         --bg: linear-gra**nt(180deg, #880000, #880000);
  223.         position: absolute;z-index: 6;
  224.         left: 40%;
  225.         transform: translate(-50%);
  226.         top: 72%;
  227.         font:normal 3em 华文隶书;
  228.         color: #0000;
  229.         white-space: pre; transform: perspective(120px) rotateY(20deg);
  230.         -webkit-background-clip: text;
  231.         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);
  232. }
  233. #lrc::before {
  234.         position: absolute;
  235.         content: attr(data-lrc);
  236.         width: 20%;
  237.         height: 100%;
  238.         color: transparent;
  239.         overflow: hidden;
  240.         white-space: pre;
  241.         background: var(--bg);
  242.        
  243.         -webkit-background-clip: text;
  244.         animation: var(--motion) var(--tt) linear forwards;
  245.         animation-play-state: var(--state);
  246. }
  247. @keyframes cover1 { from { width: 0; } to { width: 100%;} }
  248. @keyframes cover2  { from { width: 0; } to { width: 100%;} }
  249. </style>
  250. <script >
  251. (function() {
  252. /*原始lrc歌词*/
  253. let lrcStr = `[00:00.000]我爱你勐巴拉娜西
  254. [00:10.350]演唱:亮剑袁雪儿
  255. [00:20.350]LRC:老谟深虑
  256. [00:32.700]你是一杯甘甜的美酒
  257. [00:41.970]醉了蓝天醉了那白云
  258. [00:49.500]醉了太阳醉了月亮
  259. [00:57.000]醉了丛林醉了那山冈
  260. [01:06.390]飘来了辽崖山的彩铃
  261. [01:10.170]飘来了羁落山的欢乐
  262. [01:13.920]飘来了布拉山的花香
  263. [01:17.700]飘来了待牵人的清幽
  264. [01:22.350]喔我爱你哟勐巴拉娜西
  265. [01:31.020]我爱你哟勐巴拉娜西
  266. [01:40.590]风华花开千万朵
  267. [01:43.890]野桂花下飘万里
  268. [01:48.150]孔雀飞向在明天
  269. [01:51.420]就像飞水撒满天
  270. [02:27.060]你是一朵期盼的蓓蕾
  271. [02:36.420]醉了神力的风醉了那班子的云
  272. [02:43.920]醉了江河的水醉了那明朗的月
  273. [02:51.420]醉了阿布朗的情醉了那萨朵里的爱
  274. [03:00.810]美丽富饶的地方
  275. [03:04.560]人间幸福的天堂
  276. [03:08.190]神奇美丽的家园
  277. [03:12.030]人人向往的胜地
  278. [03:16.710]喔我爱你哟勐巴拉娜西
  279. [03:25.440]我爱你哟勐巴拉娜西
  280. [03:32.790]你是一颗神奇的绿宝石
  281. [03:38.250]镶嵌在那绿海里
  282. [03:42.480]你是一颗璀璨的夜明珠
  283. [03:45.810]闪烁在那花丛中
  284. [03:47.790]喔我爱你哟勐巴拉娜西
  285. [03:59.160]我爱你哟勐巴拉娜西
  286. [04:08.760]你是一颗神奇的绿宝石
  287. [04:12.060]匿舵寐避穿五洲
  288. [04:16.260]你是一颗璀璨的夜明珠
  289. [04:19.620]名扬四海闯天下
  290. [04:25.170]喔我爱你喔勐巴拉娜西
  291. [04:40.080]喔我爱你喔勐巴拉娜西
  292. `;

  293. /*变量 :mKey - 当前歌词索引;mFlag :调用关键帧动画索引;averAdd :平均值补偿*/
  294. let mKey = 0, mFlag = true, averAdd = 0.3;

  295. /*函数 :获取每句歌词用时,歌词用时若超过平均值则取平均值,最后一句歌词则取平均值*/
  296. let lrcTime = (ar) => {
  297.         let tmpAr = [];
  298.         for(j = 0; j <ar.length - 1; j ++) {
  299.                 if(j !== ar.length - 1) tmpAr[j] = parseFloat((ar[j+1][0] - ar[j][0]).toFixed(1));
  300.         }
  301.         let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
  302.         tmpAr.push(aver);
  303.         tmpAr.forEach((item,key) => {
  304.                 ar[key][2] = item > aver ? aver : item;
  305.         });
  306.         return ar;
  307. };

  308. /*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
  309. let getLrcAr = (text) => {
  310.         let lrcAr = [];
  311.         let calcRule = [60,1,0.001];
  312.         for(x of text.split('\n')) {
  313.                 let ar = [];
  314.                 let re = /\d+[\.:]\d+([\.:]\d+)?/g;
  315.                 let geci = x.replace(re,'');
  316.                 if(geci) {
  317.                         geci = geci.replace(/[\[\]\'"\t,]s?/g,'');
  318.                         let time = x.match(re);
  319.                         if(time != null) {
  320.                                 for(y of time) {
  321.                                         let tmp = y.match(/\d+/g);
  322.                                         let sec = 0;
  323.                                         for(z in tmp) sec += tmp[z] * calcRule[z];
  324.                                         ar[0] = [parseFloat(sec.toFixed(2)), geci];
  325.                                         lrcAr.push(ar[0]);
  326.                                 }
  327.                         }
  328.                 }
  329.         }
  330.         lrcAr.sort((a,b)=> a[0] - b[0]);
  331.         return(lrcTime(lrcAr));
  332. };

  333. /*函数 :模拟显示同步歌词*/
  334. let showLrc = (time) => {
  335.         let name = mFlag ? 'cover1' : 'cover2';
  336.         lrc.innerHTML = lrcAr[mKey][1];
  337.         lrc.dataset.lrc = lrcAr[mKey][1];
  338.         lrc.style.setProperty('--motion', name);
  339.         lrc.style.setProperty('--tt', time + 's');
  340.         lrc.style.setProperty('--state', 'running');
  341.         mKey += 1;
  342.         mFlag = !mFlag;
  343. };

  344. /*函数 :处理当前歌词索引 mKey*/
  345. let calcKey = () => {
  346.         for (j = 0; j < lrcAr.length; j++) {
  347.                 if (aud.currentTime <= lrcAr[j][0]) {
  348.                         mKey = j - 1;
  349.                         break;
  350.                 }
  351.         }
  352.         if (mKey < 0) mKey = 0;
  353.         if (mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;
  354.         let time = lrcAr[mKey][2] - (aud.currentTime - lrcAr[mKey][0]);
  355.         showLrc(time);
  356. };

  357. /*格式化时间信息*/
  358. let toMin = (val) => {
  359.         if (!val) return '00:00';
  360.         val = Math.floor(val);
  361.         let min = parseInt(val / 60),
  362.         sec = parseFloat(val % 60);
  363.         if (min < 10) min = '0' + min;
  364.         if (sec < 10) sec = '0' + sec;
  365.         return min + ':' + sec;
  366. }

  367. /*函数 :关键帧动画状态切换*/
  368. let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),mplayer.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),mplayer.style.animationPlayState = 'running');

  369. /*监听播放进度*/
  370. aud.addEventListener('timeupdate', () => {
  371.         for (j = 0; j < lrcAr.length; j++) {
  372.                 if (aud.currentTime >= lrcAr[j][0]) {
  373.                         cKey = j;
  374.                         if (mKey === j) showLrc(lrcAr[j][2]);
  375.                         else continue;
  376.                 }
  377.         }
  378. });
  379. aud.addEventListener('pause', () => mState());/*监听暂停事件*/
  380. aud.addEventListener('play', () => mState());/*监听播放事件*/
  381. aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
  382. let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
  383. })();

  384. </script>
  385. <script>
  386. let mState = () => aud.paused ? (mplayer.style.setProperty('--disp1','1'), mplayer.style.setProperty('--disp2','0')) : (mplayer.style.setProperty('--disp1','0'), mplayer.style.setProperty('--disp2','1'));
  387. mplayer.onclick =function() { aud.paused ?(aud.play(),imagelb.play()): ( aud.pause(),imagelb.stop())};
  388. aud.addEventListener('play', () => mState());
  389. aud.addEventListener('pause', () => mState());
  390. var imagelb= document.getElementById("lbImg");

  391. (function(){
  392. var image = document.getElementById("testImg");var image0 = document.getElementById("tnpmImg");
  393. let mState = () => aud.paused ? (image.classList.add('stop'),image0.classList.add('stop')):(image.classList.remove('stop'),image0.classList.remove('stop'));
  394. aud.addEventListener('play', () => mState());
  395. aud.addEventListener('pause', () => mState());
  396. })();
  397. bjbs.style.animationPlayState = aud.paused ? 'paused' : 'running';
  398. aud.addEventListener('playing', () =>bjbs.style.animationPlayState = 'running');
  399. aud.addEventListener('pause', () =>bjbs.style.animationPlayState = 'paused');


  400. /*进度条 进度时间*/
  401. prog.onclick = (e) => {
  402.                 aud.currentTime = aud.duration * e.offsetX / prog.offsetWidth;
  403.         }
  404. aud.addEventListener('timeupdate', () => {
  405.                aud.addEventListener('timeupdate', () => {prog.style.background= 'linear-gra**nt(90deg, #ff0000, #ff0000, #ff0000 '+ aud.currentTime / aud.duration * 100 + '%, #eeeeee 0)';});
  406.                 tmsg.innerText = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);

  407.         });
  408. let toMin = (val) => {
  409.                 if (!val) return '00:00';
  410.                 val = Math.floor(val);
  411.                 let min = parseInt(val / 60),
  412.                         sec = parseFloat(val % 60);
  413.                 if (min < 10) min = '0' + min;
  414.                 if (sec < 10) sec = '0' + sec;
  415.                 return min + ':' + sec;
  416.         };
  417. /*结束*/
  418. </script>
  419. <script>
  420. /*以下是控制动图的插件*/
  421. if ('getContext' in document.createElement('canvas')) {
  422.     HTMLImageElement.prototype.play = function() {
  423.         if (this.storeCanvas) {
  424.             // 移除存储的canvas
  425.             this.storeCanvas.parentElement.removeChild(this.storeCanvas);
  426.             this.storeCanvas = null;
  427.             // 透明度还原
  428.             imagelb.style.opacity = '';
  429.         }
  430.         if (this.storeUrl) {
  431.             this.src = this.storeUrl;   
  432.         }
  433.     };
  434.     HTMLImageElement.prototype.stop = function() {
  435.         var canvas = document.createElement('canvas');
  436.         // 尺寸
  437.         var width = this.width, height = this.height;
  438.         if (width && height) {
  439.             // 存储之前的地址
  440.             if (!this.storeUrl) {
  441.                 this.storeUrl = this.src;
  442.             }
  443.             // canvas大小
  444.             canvas.width = width;
  445.             canvas.height = height;
  446.             // 绘制图片帧(第一帧)
  447.             canvas.getContext('2d').drawImage(this, 0, 0, width, height);
  448.             // 重置当前图片
  449.             try {
  450.                 this.src = canvas.toDataURL("image/gif");
  451.             } catch(e) {
  452.                 // 跨域
  453.                 this.removeAttribute('src');
  454.                 // 载入canvas元素
  455.                 canvas.style.position = 'absolute';
  456.                 // 前面插入图片
  457.                 this.parentElement.insertBefore(canvas, this);
  458.                 // 隐藏原图
  459.                 this.style.opacity = '0';
  460.                 // 存储canvas
  461.                 this.storeCanvas = canvas;
  462.             }
  463.         }
  464.     };
  465. }

  466. </script>
复制代码


204

主题

7452

回帖

4万

积分

版主

积分
43550
发表于 2025-2-15 12:45:00 | 显示全部楼层 IP:

360浏览器

498

主题

2万

回帖

11万

积分

超级版主

积分
116893
 楼主| 发表于 2025-2-15 12:50:08 | 显示全部楼层 IP:亚太地区

       看来只有360浏览器能听到声音。

214

主题

7750

回帖

6万

积分

版主

积分
63302
发表于 2025-2-15 12:53:49 | 显示全部楼层 IP:澳大利亚
出大错了老乡,没有声音。

498

主题

2万

回帖

11万

积分

超级版主

积分
116893
 楼主| 发表于 2025-2-15 12:56:30 | 显示全部楼层 IP:亚太地区
丁香 发表于 2025-2-15 12:53
出大错了老乡,没有声音。

       对的,有人能听到,有人听不到。没办法了。

204

主题

7452

回帖

4万

积分

版主

积分
43550
发表于 2025-2-15 13:04:44 | 显示全部楼层 IP:
老谟深虑 发表于 2025-2-15 12:50
看来只有360浏览器能听到声音。

我现在用了搜狗也可以听到音乐。

144

主题

6034

回帖

3万

积分

蓬莱仙人

积分
36139
发表于 2025-2-15 13:06:00 | 显示全部楼层 IP:黑龙江
欣赏您精心编辑的优美音画,听到《我爱你勐巴拉娜西》这首歌,我感觉就像是被带到了一个遥远而又神秘的地方,歌曲里的旋律和歌词都充满了浓郁的民族风情,让人仿佛能感受到那片美丽土地的魅力。欣赏老谟超版佳作,我也忍不住想要跟着歌曲一起舞蹈,感受那份热烈和欢快!点赞!学习!
温馨提示:请朋友们转换浏览器,用360能够听到声音,很动听的一首歌,非常喜欢!

31

主题

8204

回帖

4万

积分

超级版主

积分
40777
发表于 2025-2-15 14:14:25 | 显示全部楼层 IP:福建厦门

好!

31

主题

8204

回帖

4万

积分

超级版主

积分
40777
发表于 2025-2-15 14:28:57 | 显示全部楼层 IP:福建厦门
武朝歌 发表于 2025-2-15 11:38
360浏览器事儿多。

对!不敢安装!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-10 00:29 , Processed in 0.096250 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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