From 49c5360680542af91a5c477f635aedd094e358e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Tue, 24 Oct 2023 05:06:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/music.js | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/music.js b/src/music.js index 9055620..5cf9f6b 100644 --- a/src/music.js +++ b/src/music.js @@ -242,6 +242,12 @@ export default class MusicList { this.ul.appendChild(ListItem({ id: item.id, classList: item.arrayBuffer ? ['cache'] : [], + style: { + display: 'flex', + alignItems: 'center', + justifyContent: 'space-between', + gap: '.25rem', + }, children: [ ...(item.picture ? [Img({ src: item.picture, @@ -349,27 +355,6 @@ export default class MusicList { } else { this.标题.textContent = item.name // 替换标题 this.封面.src = item.picture // 替换封面图像 - - //// item.picture 是一个base64编码的图片, 获取图片的宽高和格式 - //const [width, height, format] = (() => { - // const [, base64] = item.picture.split(',') - // const binary = atob(base64) - // const bytes = new Uint8Array(binary.length) - // for (let i = 0; i < binary.length; i++) { - // bytes[i] = binary.charCodeAt(i) - // } - // const blob = new Blob([bytes.buffer], { type: item.type }) - // const url = URL.createObjectURL(blob) - // const img = new Image() - // img.src = url - // return new Promise(resolve => { - // img.onload = () => { - // resolve([img.width, img.height, img.src.split('.').pop()]) - // } - // }) - //}) - //console.log('封面信息:', width, height, format) - // 替换浏览器媒体信息(使系统通知栏显示歌曲信息) if ('mediaSession' in navigator) { navigator.mediaSession.metadata = new MediaMetadata({ @@ -377,9 +362,9 @@ export default class MusicList { artist: '艺术家名', album: '专辑名', artwork: [ - { src: item.picture, sizes: '96x96', type: 'image/png' }, + { src: item.picture, sizes: '96x96', type: 'image/jpeg' }, ] - }); + }) } // 本地缓存直接播放 this.audio.src = URL.createObjectURL(new Blob([item.arrayBuffer], { type: item.type }))