mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-05-23 22:37:41 +08:00
flac 添加
This commit is contained in:
parent
df808d1504
commit
57d6425a56
@ -16,7 +16,7 @@ import { apis } from '@/utils/musicSdk/api-source'
|
|||||||
const getOtherSourcePromises = new Map()
|
const getOtherSourcePromises = new Map()
|
||||||
export const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
|
export const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
|
||||||
|
|
||||||
export const getOtherSource = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, isRefresh = false): Promise<LX.Music.MusicInfoOnline[]> => {
|
export const getOtherSource = async (musicInfo: LX.Music.MusicInfo | LX.Download.ListItem, isRefresh = false): Promise<LX.Music.MusicInfoOnline[]> => {
|
||||||
if (!isRefresh) {
|
if (!isRefresh) {
|
||||||
const cachedInfo = await getOtherSourceFromStore(musicInfo.id)
|
const cachedInfo = await getOtherSourceFromStore(musicInfo.id)
|
||||||
if (cachedInfo.length) return cachedInfo
|
if (cachedInfo.length) return cachedInfo
|
||||||
@ -71,7 +71,7 @@ export const getOtherSource = async(musicInfo: LX.Music.MusicInfo | LX.Download.
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const buildLyricInfo = async(lyricInfo: MakeOptional<LX.Player.LyricInfo, 'rawlrcInfo'>): Promise<LX.Player.LyricInfo> => {
|
export const buildLyricInfo = async (lyricInfo: MakeOptional<LX.Player.LyricInfo, 'rawlrcInfo'>): Promise<LX.Player.LyricInfo> => {
|
||||||
if (!settingState.setting['player.isS2t']) {
|
if (!settingState.setting['player.isS2t']) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
if (lyricInfo.rawlrcInfo) return lyricInfo
|
if (lyricInfo.rawlrcInfo) return lyricInfo
|
||||||
@ -117,7 +117,7 @@ export const buildLyricInfo = async(lyricInfo: MakeOptional<LX.Player.LyricInfo,
|
|||||||
return lyricInfo.rawlrcInfo ? lyricInfo : { ...lyricInfo, rawlrcInfo: { ...lyricInfo } }
|
return lyricInfo.rawlrcInfo ? lyricInfo : { ...lyricInfo, rawlrcInfo: { ...lyricInfo } }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCachedLyricInfo = async(musicInfo: LX.Music.MusicInfo): Promise<LX.Player.LyricInfo | null> => {
|
export const getCachedLyricInfo = async (musicInfo: LX.Music.MusicInfo): Promise<LX.Player.LyricInfo | null> => {
|
||||||
let lrcInfo = await getStoreLyric(musicInfo)
|
let lrcInfo = await getStoreLyric(musicInfo)
|
||||||
// lrcInfo = {}
|
// lrcInfo = {}
|
||||||
if (existTimeExp.test(lrcInfo.lyric) && lrcInfo.tlyric != null) {
|
if (existTimeExp.test(lrcInfo.lyric) && lrcInfo.tlyric != null) {
|
||||||
@ -146,7 +146,7 @@ export const getCachedLyricInfo = async(musicInfo: LX.Music.MusicInfo): Promise<
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourceMusicUrlByLocal = async(musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
export const getOnlineOtherSourceMusicUrlByLocal = async (musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
||||||
url: string
|
url: string
|
||||||
quality: LX.Quality
|
quality: LX.Quality
|
||||||
isFromCache: boolean
|
isFromCache: boolean
|
||||||
@ -170,7 +170,7 @@ export const getOnlineOtherSourceMusicUrlByLocal = async(musicInfo: LX.Music.Mus
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourceLyricByLocal = async(musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
export const getOnlineOtherSourceLyricByLocal = async (musicInfo: LX.Music.MusicInfoLocal, isRefresh: boolean): Promise<{
|
||||||
lyricInfo: LX.Music.LyricInfo
|
lyricInfo: LX.Music.LyricInfo
|
||||||
isFromCache: boolean
|
isFromCache: boolean
|
||||||
}> => {
|
}> => {
|
||||||
@ -191,7 +191,7 @@ export const getOnlineOtherSourceLyricByLocal = async(musicInfo: LX.Music.MusicI
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourcePicByLocal = async(musicInfo: LX.Music.MusicInfoLocal): Promise<{
|
export const getOnlineOtherSourcePicByLocal = async (musicInfo: LX.Music.MusicInfoLocal): Promise<{
|
||||||
url: string
|
url: string
|
||||||
}> => {
|
}> => {
|
||||||
if (!await global.lx.apiInitPromise[0]) throw new Error('source init failed')
|
if (!await global.lx.apiInitPromise[0]) throw new Error('source init failed')
|
||||||
@ -211,11 +211,11 @@ export const getOnlineOtherSourcePicByLocal = async(musicInfo: LX.Music.MusicInf
|
|||||||
export const getPlayQuality = (highQuality: boolean, musicInfo: LX.Music.MusicInfoOnline): LX.Quality => {
|
export const getPlayQuality = (highQuality: boolean, musicInfo: LX.Music.MusicInfoOnline): LX.Quality => {
|
||||||
let type: LX.Quality = '128k'
|
let type: LX.Quality = '128k'
|
||||||
let list = global.lx.qualityList[musicInfo.source]
|
let list = global.lx.qualityList[musicInfo.source]
|
||||||
if (highQuality && musicInfo.meta._qualitys['320k'] && list && list.includes('320k')) type = '320k'
|
if (highQuality && musicInfo.meta._qualitys['flac'] && list && list.includes('flac')) type = 'flac'
|
||||||
return type
|
return type
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getOnlineOtherSourceMusicUrl = async({ musicInfos, quality, onToggleSource, isRefresh, retryedSource = [] }: {
|
export const getOnlineOtherSourceMusicUrl = async ({ musicInfos, quality, onToggleSource, isRefresh, retryedSource = [] }: {
|
||||||
musicInfos: LX.Music.MusicInfoOnline[]
|
musicInfos: LX.Music.MusicInfoOnline[]
|
||||||
quality?: LX.Quality
|
quality?: LX.Quality
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
@ -269,7 +269,7 @@ export const getOnlineOtherSourceMusicUrl = async({ musicInfos, quality, onToggl
|
|||||||
/**
|
/**
|
||||||
* 获取在线音乐URL
|
* 获取在线音乐URL
|
||||||
*/
|
*/
|
||||||
export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSource, isRefresh, allowToggleSource }: {
|
export const handleGetOnlineMusicUrl = async ({ musicInfo, quality, onToggleSource, isRefresh, allowToggleSource }: {
|
||||||
musicInfo: LX.Music.MusicInfoOnline
|
musicInfo: LX.Music.MusicInfoOnline
|
||||||
quality?: LX.Quality
|
quality?: LX.Quality
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -293,7 +293,7 @@ export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSourc
|
|||||||
}
|
}
|
||||||
return reqPromise.then(({ url, type }: { url: string, type: LX.Quality }) => {
|
return reqPromise.then(({ url, type }: { url: string, type: LX.Quality }) => {
|
||||||
return { musicInfo, url, quality: type, isFromCache: false }
|
return { musicInfo, url, quality: type, isFromCache: false }
|
||||||
}).catch(async(err: any) => {
|
}).catch(async (err: any) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
if (!allowToggleSource || err.message == requestMsg.tooManyRequests) throw err
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
@ -315,7 +315,7 @@ export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSourc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getOnlineOtherSourcePicUrl = async({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
export const getOnlineOtherSourcePicUrl = async ({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
||||||
musicInfos: LX.Music.MusicInfoOnline[]
|
musicInfos: LX.Music.MusicInfoOnline[]
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -358,7 +358,7 @@ export const getOnlineOtherSourcePicUrl = async({ musicInfos, onToggleSource, is
|
|||||||
/**
|
/**
|
||||||
* 获取在线歌曲封面
|
* 获取在线歌曲封面
|
||||||
*/
|
*/
|
||||||
export const handleGetOnlinePicUrl = async({ musicInfo, isRefresh, onToggleSource, allowToggleSource }: {
|
export const handleGetOnlinePicUrl = async ({ musicInfo, isRefresh, onToggleSource, allowToggleSource }: {
|
||||||
musicInfo: LX.Music.MusicInfoOnline
|
musicInfo: LX.Music.MusicInfoOnline
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -377,7 +377,7 @@ export const handleGetOnlinePicUrl = async({ musicInfo, isRefresh, onToggleSourc
|
|||||||
}
|
}
|
||||||
return reqPromise.then((url: string) => {
|
return reqPromise.then((url: string) => {
|
||||||
return { musicInfo, url, isFromCache: false }
|
return { musicInfo, url, isFromCache: false }
|
||||||
}).catch(async(err: any) => {
|
}).catch(async (err: any) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
if (!allowToggleSource) throw err
|
if (!allowToggleSource) throw err
|
||||||
onToggleSource()
|
onToggleSource()
|
||||||
@ -398,7 +398,7 @@ export const handleGetOnlinePicUrl = async({ musicInfo, isRefresh, onToggleSourc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
export const getOnlineOtherSourceLyricInfo = async ({ musicInfos, onToggleSource, isRefresh, retryedSource = [] }: {
|
||||||
musicInfos: LX.Music.MusicInfoOnline[]
|
musicInfos: LX.Music.MusicInfoOnline[]
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -433,7 +433,7 @@ export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource,
|
|||||||
reqPromise = Promise.reject(err)
|
reqPromise = Promise.reject(err)
|
||||||
}
|
}
|
||||||
// retryedSource.includes(musicInfo.source)
|
// retryedSource.includes(musicInfo.source)
|
||||||
return reqPromise.then(async(lyricInfo: LX.Music.LyricInfo) => {
|
return reqPromise.then(async (lyricInfo: LX.Music.LyricInfo) => {
|
||||||
return existTimeExp.test(lyricInfo.lyric) ? {
|
return existTimeExp.test(lyricInfo.lyric) ? {
|
||||||
lyricInfo,
|
lyricInfo,
|
||||||
musicInfo,
|
musicInfo,
|
||||||
@ -449,7 +449,7 @@ export const getOnlineOtherSourceLyricInfo = async({ musicInfos, onToggleSource,
|
|||||||
/**
|
/**
|
||||||
* 获取在线歌词信息
|
* 获取在线歌词信息
|
||||||
*/
|
*/
|
||||||
export const handleGetOnlineLyricInfo = async({ musicInfo, onToggleSource, isRefresh, allowToggleSource }: {
|
export const handleGetOnlineLyricInfo = async ({ musicInfo, onToggleSource, isRefresh, allowToggleSource }: {
|
||||||
musicInfo: LX.Music.MusicInfoOnline
|
musicInfo: LX.Music.MusicInfoOnline
|
||||||
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
onToggleSource: (musicInfo?: LX.Music.MusicInfoOnline) => void
|
||||||
isRefresh: boolean
|
isRefresh: boolean
|
||||||
@ -467,13 +467,13 @@ export const handleGetOnlineLyricInfo = async({ musicInfo, onToggleSource, isRef
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
reqPromise = Promise.reject(err)
|
reqPromise = Promise.reject(err)
|
||||||
}
|
}
|
||||||
return reqPromise.then(async(lyricInfo: LX.Music.LyricInfo) => {
|
return reqPromise.then(async (lyricInfo: LX.Music.LyricInfo) => {
|
||||||
return existTimeExp.test(lyricInfo.lyric) ? {
|
return existTimeExp.test(lyricInfo.lyric) ? {
|
||||||
musicInfo,
|
musicInfo,
|
||||||
lyricInfo,
|
lyricInfo,
|
||||||
isFromCache: false,
|
isFromCache: false,
|
||||||
} : Promise.reject(new Error('failed'))
|
} : Promise.reject(new Error('failed'))
|
||||||
}).catch(async(err: any) => {
|
}).catch(async (err: any) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
if (!allowToggleSource) throw err
|
if (!allowToggleSource) throw err
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@
|
|||||||
"setting_play_handle_audio_focus": "When other apps play sound, automatically pause the playback",
|
"setting_play_handle_audio_focus": "When other apps play sound, automatically pause the playback",
|
||||||
"setting_play_handle_audio_focus_tip": "Take effect after restarting the application",
|
"setting_play_handle_audio_focus_tip": "Take effect after restarting the application",
|
||||||
"setting_play_lyric_transition": "Show lyrics translation",
|
"setting_play_lyric_transition": "Show lyrics translation",
|
||||||
"setting_play_quality": "Play 320K quality songs first (if supported)",
|
"setting_play_quality": "Play flac quality songs first (if supported)",
|
||||||
"setting_play_s2t": "Convert the played lyrics to Traditional Chinese",
|
"setting_play_s2t": "Convert the played lyrics to Traditional Chinese",
|
||||||
"setting_play_save_play_time": "Remember playback progress",
|
"setting_play_save_play_time": "Remember playback progress",
|
||||||
"setting_play_show_notification_image": "Show song picture in notification bar",
|
"setting_play_show_notification_image": "Show song picture in notification bar",
|
||||||
@ -499,4 +499,4 @@
|
|||||||
"version_title_new": "🌟 New version found 🌟",
|
"version_title_new": "🌟 New version found 🌟",
|
||||||
"version_title_unknown": "❓ Failed to get the latest version information ❓",
|
"version_title_unknown": "❓ Failed to get the latest version information ❓",
|
||||||
"version_title_update": "🚀 Program update 🚀"
|
"version_title_update": "🚀 Program update 🚀"
|
||||||
}
|
}
|
@ -338,7 +338,7 @@
|
|||||||
"setting_play_handle_audio_focus": "其他应用播放声音时,自动暂停播放",
|
"setting_play_handle_audio_focus": "其他应用播放声音时,自动暂停播放",
|
||||||
"setting_play_handle_audio_focus_tip": "重启应用后生效",
|
"setting_play_handle_audio_focus_tip": "重启应用后生效",
|
||||||
"setting_play_lyric_transition": "显示歌词翻译",
|
"setting_play_lyric_transition": "显示歌词翻译",
|
||||||
"setting_play_quality": "优先播放320K品质的歌曲(如果支持)",
|
"setting_play_quality": "优先播放flac品质的歌曲(如果支持)",
|
||||||
"setting_play_s2t": "将播放的歌词转繁体",
|
"setting_play_s2t": "将播放的歌词转繁体",
|
||||||
"setting_play_save_play_time": "记住播放进度",
|
"setting_play_save_play_time": "记住播放进度",
|
||||||
"setting_play_show_notification_image": "在通知栏显示歌曲图片",
|
"setting_play_show_notification_image": "在通知栏显示歌曲图片",
|
||||||
@ -499,4 +499,4 @@
|
|||||||
"version_title_new": "🌟 发现新版本 🌟",
|
"version_title_new": "🌟 发现新版本 🌟",
|
||||||
"version_title_unknown": "❓ 获取最新版本信息失败 ❓",
|
"version_title_unknown": "❓ 获取最新版本信息失败 ❓",
|
||||||
"version_title_update": "🚀 程序更新 🚀"
|
"version_title_update": "🚀 程序更新 🚀"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user