显示换源提示
parent
920d696d0b
commit
b6c1403f4b
|
@ -609,7 +609,14 @@ export default {
|
||||||
// this.musicInfo.url = await getMusicUrl(targetSong, type)
|
// this.musicInfo.url = await getMusicUrl(targetSong, type)
|
||||||
this.status = this.statusText = this.$t('core.player.geting_url')
|
this.status = this.statusText = this.$t('core.player.geting_url')
|
||||||
|
|
||||||
return this.getUrl({ musicInfo: targetSong, type, isRefresh }).then(url => {
|
return this.getUrl({
|
||||||
|
musicInfo: targetSong,
|
||||||
|
type,
|
||||||
|
isRefresh,
|
||||||
|
onToggleSource: () => {
|
||||||
|
this.status = this.statusText = 'Try toggle source...'
|
||||||
|
},
|
||||||
|
}).then(url => {
|
||||||
if (targetSong !== this.targetSong || this.isPlay) return
|
if (targetSong !== this.targetSong || this.isPlay) return
|
||||||
audio.src = this.musicInfo.url = url
|
audio.src = this.musicInfo.url = url
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|
|
@ -67,7 +67,7 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMusicUrl = function(musicInfo, type, retryedSource = [], originMusic) {
|
const getMusicUrl = function(musicInfo, type, onToggleSource, retryedSource = [], originMusic) {
|
||||||
// console.log(musicInfo.source)
|
// console.log(musicInfo.source)
|
||||||
if (!originMusic) originMusic = musicInfo
|
if (!originMusic) originMusic = musicInfo
|
||||||
let reqPromise
|
let reqPromise
|
||||||
|
@ -78,13 +78,14 @@ const getMusicUrl = function(musicInfo, type, retryedSource = [], originMusic) {
|
||||||
}
|
}
|
||||||
return reqPromise.catch(err => {
|
return reqPromise.catch(err => {
|
||||||
if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source)
|
if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source)
|
||||||
|
onToggleSource()
|
||||||
return this.dispatch('list/getOtherSource', originMusic).then(otherSource => {
|
return this.dispatch('list/getOtherSource', originMusic).then(otherSource => {
|
||||||
console.log('find otherSource', otherSource)
|
console.log('find otherSource', otherSource)
|
||||||
if (otherSource.length) {
|
if (otherSource.length) {
|
||||||
for (const item of otherSource) {
|
for (const item of otherSource) {
|
||||||
if (retryedSource.includes(item.source) || !assertApiSupport(item.source)) continue
|
if (retryedSource.includes(item.source) || !assertApiSupport(item.source)) continue
|
||||||
console.log('try toggle to: ', item.source, item.name, item.singer, item.interval)
|
console.log('try toggle to: ', item.source, item.name, item.singer, item.interval)
|
||||||
return getMusicUrl.call(this, item, type, retryedSource, originMusic)
|
return getMusicUrl.call(this, item, type, onToggleSource, retryedSource, originMusic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
|
@ -189,7 +190,7 @@ const getters = {
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
const actions = {
|
const actions = {
|
||||||
async getUrl({ commit, state }, { musicInfo, type, isRefresh }) {
|
async getUrl({ commit, state }, { musicInfo, type, isRefresh, onToggleSource = () => {} }) {
|
||||||
if (!musicInfo._types[type]) {
|
if (!musicInfo._types[type]) {
|
||||||
// 兼容旧版酷我源搜索列表过滤128k音质的bug
|
// 兼容旧版酷我源搜索列表过滤128k音质的bug
|
||||||
if (!(musicInfo.source == 'kw' && type == '128k')) throw new Error('该歌曲没有可播放的音频')
|
if (!(musicInfo.source == 'kw' && type == '128k')) throw new Error('该歌曲没有可播放的音频')
|
||||||
|
@ -199,7 +200,7 @@ const actions = {
|
||||||
const cachedUrl = await getStoreMusicUrl(musicInfo, type)
|
const cachedUrl = await getStoreMusicUrl(musicInfo, type)
|
||||||
if (cachedUrl && !isRefresh) return cachedUrl
|
if (cachedUrl && !isRefresh) return cachedUrl
|
||||||
|
|
||||||
return getMusicUrl.call(this, musicInfo, type).then(({ url }) => {
|
return getMusicUrl.call(this, musicInfo, type, onToggleSource).then(({ url }) => {
|
||||||
commit('setUrl', { musicInfo, url, type })
|
commit('setUrl', { musicInfo, url, type })
|
||||||
return url
|
return url
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|
Loading…
Reference in New Issue