对齐
This commit is contained in:
parent
3c02e2dc82
commit
49c5360680
31
src/music.js
31
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 }))
|
||||
|
Loading…
Reference in New Issue
Block a user