QQMCC 欢迎你的回来。
快捷导航

[音乐表格] 音乐左右代码

154 主题
星币
金钱

Rank: 16Rank: 16Rank: 16Rank: 16

发表于 5 天前 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转QQMCC。

您需要 登录 才可以下载或查看,没有账号?注册

x

1400x1400bb.jpg

281公里

谢霆锋
追逐里程,或者选择追逐雨
逃避人群,不是有心逃避你。
00:00 03:00

回复

使用道具 举报

154 主题
星币
金钱

Rank: 16Rank: 16Rank: 16Rank: 16

 楼主| 发表于 5 天前 | 显示全部楼层
  1. <br>
  2. <style>
  3. .music-card-neon{
  4.     width:100%;
  5.     max-width:620px;
  6.     margin:10px auto;
  7.     backdrop-filter:blur(14px);
  8.     border-radius:34px;
  9.     padding:18px;
  10.     box-sizing:border-box;
  11.     overflow:hidden;
  12.     font-family:system-ui,sans-serif;
  13. }
  14. .music-card-row{
  15.     display:flex;
  16.     align-items:center;
  17.     gap:14px;
  18. }
  19. .music-cover{
  20.     width:220px;
  21.     height:220px;
  22.     min-width:110px;
  23.     border-radius:20px;
  24.     overflow:hidden;
  25.     background:#eee;
  26. }
  27. .music-cover img{
  28.     width:100%;
  29.     height:100%;
  30.     object-fit:cover;
  31.     display:block;
  32. }
  33. .music-info{
  34.     flex:1;
  35.     min-width:0;
  36. }
  37. .music-title-wrap{
  38.     display:flex;
  39.     align-items:center;
  40.     justify-content:space-between;
  41.     gap:8px;
  42.     margin-bottom:4px;
  43. }
  44. .music-title{
  45.     font-size:22px !important;
  46.     font-weight:700;
  47.     color:#222;
  48.     margin:0;
  49.     white-space:nowrap;
  50.     overflow:hidden;
  51.     text-overflow:ellipsis;
  52. }
  53. .like-wrap{
  54.     position:relative;
  55.     cursor:pointer;
  56.     flex-shrink:0;
  57. }
  58. .like-icon{
  59.     width:24px;
  60.     height:24px;
  61.     display:block;
  62. }
  63. .music-artist{
  64.     font-size:14px;
  65.     color:#444;
  66.     margin:0 0 6px;
  67. }
  68. .music-lyric-tip{
  69.     font-size:12px;
  70.     color:#666;
  71.     margin:0 0 10px;
  72.     line-height:1.4;
  73.     display:-webkit-box;
  74.     -webkit-line-clamp:2;
  75.     -webkit-box-orient:vertical;
  76.     overflow:hidden;
  77. }
  78. .music-progress-box{
  79.     width:100%;
  80. }
  81. .music-time-row{
  82.     display:flex;
  83.     justify-content:space-between;
  84.     font-size:11px;
  85.     color:#666;
  86.     margin-bottom:4px;
  87. }
  88. .music-progress{
  89.     width:100%;
  90.     height:3px;
  91.     background:#dddddd;
  92.     border-radius:99px;
  93.     cursor:pointer;
  94.     position:relative;
  95. }
  96. .music-progress-bar{
  97.     height:100%;
  98.     width:0%;
  99.     background:#222;
  100.     border-radius:99px;
  101. }
  102. .music-control{
  103.     display:flex;
  104.     align-items:center;
  105.     justify-content:space-between;
  106.     margin-top:10px;
  107. }
  108. .music-icon-btn{
  109.     border:none;
  110.     background:transparent;
  111.     padding:0;
  112.     cursor:pointer;
  113. }
  114. .music-icon-btn img{
  115.     width:22px;
  116.     height:22px;
  117.     display:block;
  118. }
  119. .music-play-btn{
  120.     border:none;
  121.     background:#ffffff;
  122.     width:46px;
  123.     height:46px;
  124.     border-radius:50%;
  125.     padding:0;
  126.     display:flex;
  127.     align-items:center;
  128.     justify-content:center;
  129.     box-shadow:0 2px 8px rgba(0,0,0,0.12);
  130.     cursor:pointer;
  131. }
  132. .music-play-btn img{
  133.     width:22px;
  134.     height:22px;
  135.     display:block;
  136. }
  137. .music-audio{
  138.     display:none;
  139. }
  140. </style>
  141. <div class="music-card-neon" id="musicCard">
  142.     <div class="music-card-row">
  143.         <div class="music-cover">
  144.             
  145.         </div>

  146.         <div class="music-info">
  147.             <div class="music-title-wrap">
  148.                 <h2 class="music-title">281公里</h2>
  149.                 <div class="like-wrap" id="likeWrap">
  150.                     <img class="like-icon" id="likeIcon" src="https://www.qqmcc.net/data/attachment/album/202610/22/160519yh2qmxmyrh2xcqmc.png" alt="收藏">
  151.                 </div>
  152.             </div>

  153.             <div class="music-artist">谢霆锋</div>
  154.             <div class="music-lyric-tip">追逐里程,或者选择追逐雨<br>逃避人群,不是有心逃避你。</div>

  155.             <div class="music-progress-box">
  156.                 <div class="music-time-row">
  157.                     <span id="curTime">00:00</span>
  158.                     <span id="totalTime">03:00</span>
  159.                 </div>
  160.                 <div class="music-progress" id="progressWrap">
  161.                     <div class="music-progress-bar" id="progressBar"></div>
  162.                 </div>
  163.             </div>

  164.             <div class="music-control">
  165.                 <button class="music-icon-btn" id="loopBtn">
  166.                     <img src="https://www.qqmcc.net/data/attachment/album/202610/22/155730vnammnln61bttn5g.png" alt="循环">
  167.                 </button>
  168.                 <button class="music-icon-btn" id="prevBtn">
  169.                     <img src="https://www.qqmcc.net/data/attachment/album/202610/22/155730a4pbp8pnep7ppp47.png" alt="上一曲">
  170.                 </button>
  171.                 <button class="music-play-btn" id="playBtn">
  172.                     <img id="playIcon" src="https://www.qqmcc.net/data/attachment/album/202610/22/155731nb5pk2epp2dmmzc5.png" alt="暂停">
  173.                 </button>
  174.                 <button class="music-icon-btn" id="nextBtn">
  175.                     <img src="https://www.qqmcc.net/data/attachment/album/202610/22/155730f3yog1tdtdkx40wg.png" alt="下一曲">
  176.                 </button>
  177.                 <button class="music-icon-btn" id="listBtn">
  178.                     <img src="https://www.qqmcc.net/data/attachment/album/202610/22/155730wr9t66s1lb19mdz4.png" alt="列表">
  179.                 </button>
  180.             </div>
  181.         </div>
  182.     </div>

  183.     <audio class="music-audio" id="audioPlayer">
  184.       
  185. </div>

  186. <script>
  187. function fmtTime(s){
  188.     let m = Math.floor(s / 60);
  189.     let sec = Math.floor(s % 60);
  190.     return String(m).padStart(2,'0')+':'+String(sec).padStart(2,'0');
  191. }

  192. let timer = null;
  193. let pos = 0;
  194. const total = 180;
  195. let run = true;

  196. const curTimeDom = document.getElementById('curTime');
  197. const progressBar = document.getElementById('progressBar');
  198. const progressWrap = document.getElementById('progressWrap');
  199. const playIcon = document.getElementById('playIcon');
  200. const audio = document.getElementById('audioPlayer');

  201. function updateView(){
  202.     progressBar.style.width = (pos/total*100)+'%';
  203.     curTimeDom.innerText = fmtTime(pos);
  204. }

  205. function startTimer(){
  206.     timer = setInterval(()=>{
  207.         pos += 0.1;
  208.         if(pos >= total){
  209.             pos = total;
  210.             stopTimer();
  211.             run = false;
  212.             playIcon.src = 'https://www.qqmcc.net/data/attachment/album/202610/22/155730rm7ldu8jdgd87y0g.png';
  213.         }
  214.         updateView();
  215.     },100);
  216. }
  217. function stopTimer(){
  218.     clearInterval(timer);
  219.     timer = null;
  220. }

  221. updateView();
  222. audio.play().catch(()=>{});
  223. startTimer();

  224. document.getElementById('playBtn').onclick = function(){
  225.     const icoPlay = 'https://www.qqmcc.net/data/attachment/album/202610/22/155730rm7ldu8jdgd87y0g.png';
  226.     const icoPause = 'https://www.qqmcc.net/data/attachment/album/202610/22/155731nb5pk2epp2dmmzc5.png';

  227.     if(run){
  228.         audio.pause();
  229.         stopTimer();
  230.         run = false;
  231.         playIcon.src = icoPlay;
  232.     }else{
  233.         audio.play().catch(()=>{});
  234.         run = true;
  235.         playIcon.src = icoPause;
  236.         startTimer();
  237.     }
  238. }

  239. progressWrap.onclick = function(e){
  240.     const wrap = this.getBoundingClientRect();
  241.     const p = (e.clientX - wrap.left)/wrap.width;
  242.     pos = p * total;
  243.     updateView();
  244. }

  245. const likeIcon = document.getElementById('likeIcon');
  246. const heartOutline = "https://www.qqmcc.net/data/attachment/album/202610/22/160519yh2qmxmyrh2xcqmc.png";
  247. const heartFill = "https://www.qqmcc.net/data/attachment/album/202610/22/160812nt71pzittbuetpfx.png";
  248. let isLike = false;
  249. document.getElementById('likeWrap').onclick = function(){
  250.     isLike = !isLike;
  251.     likeIcon.src = isLike ? heartFill : heartOutline;
  252. };

  253. const cardHex = '#DCF2D2';
  254. const cardAlpha = 0.6;
  255. function hexToRgb(hex) {
  256.     const r = parseInt(hex.slice(1, 3),16);
  257.     const g = parseInt(hex.slice(3, 5),16);
  258.     const b = parseInt(hex.slice(5, 7),16);
  259.     return `${r},${g},${b}`;
  260. }
  261. document.getElementById('musicCard').style.background = `rgba(${hexToRgb(cardHex)}, ${cardAlpha})`;

  262. document.getElementById('loopBtn').onclick = function(){};
  263. document.getElementById('prevBtn').onclick = function(){};
  264. document.getElementById('nextBtn').onclick = function(){};
  265. document.getElementById('listBtn').onclick = function(){};
  266. </script>
  267. <br>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

Archiver|小黑屋|关于我们

Copyright © 2016-2023, Tencent Cloud.    Powered by Discuz! X3.4    鄂ICP备2022014325号-7

GMT+8, 2026-10-27 09:39