播放本地歌曲时,将优先尝试读取本地同名字的 `jpg` 或 `png` 图片作为播放封面显示
parent
68ac1b7641
commit
9237dbbc18
|
@ -9,6 +9,7 @@
|
|||
- 修正搜索歌曲提示框文案(#2050)
|
||||
- 优化播放详情页UI,歌曲名字、歌手等文字过长时被截断的问题(#2049)
|
||||
- Scheme URL 的播放歌曲允许更长的专辑名称
|
||||
- 播放本地歌曲时,将优先尝试读取本地同名字的 `jpg` 或 `png` 图片作为播放封面显示,若文件不存在则从音频文件内读取,最后再尝试使用在线图片(#2096)
|
||||
|
||||
### 修复
|
||||
|
||||
|
|
|
@ -117,6 +117,13 @@ const getFileMetadata = async(path: string) => {
|
|||
* @param path 路径
|
||||
*/
|
||||
export const getLocalMusicFilePic = async(path: string) => {
|
||||
const filePath = new RegExp('\\' + extname(path) + '$')
|
||||
let picPath = path.replace(filePath, '.jpg')
|
||||
let stats = await getFileStats(picPath)
|
||||
if (stats) return picPath
|
||||
picPath = path.replace(filePath, '.png')
|
||||
stats = await getFileStats(picPath)
|
||||
if (stats) return picPath
|
||||
const metadata = await getFileMetadata(path)
|
||||
if (!metadata) return null
|
||||
const { selectCover } = await import('music-metadata')
|
||||
|
|
|
@ -15,6 +15,7 @@ const getTempDir = async() => {
|
|||
export const getMusicFilePic = async(filePath: string) => {
|
||||
const picture = await getLocalMusicFilePic(filePath)
|
||||
if (!picture) return ''
|
||||
if (typeof picture == 'string') return picture
|
||||
if (picture.data.length > 400_000) {
|
||||
try {
|
||||
const tempDir = await getTempDir()
|
||||
|
|
Loading…
Reference in New Issue