优化软件启动时恢复上一次播放的歌曲进度功能
parent
f1049169b5
commit
10e5460e39
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
- 直接从歌单详情收藏的列表新增同步功能。注意:这将会覆盖本地的目标列表,歌曲将被替换成最新的在线列表
|
- 直接从歌单详情收藏的列表新增同步功能。注意:这将会覆盖本地的目标列表,歌曲将被替换成最新的在线列表
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 优化软件启动时恢复上一次播放的歌曲进度功能
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复MAC平台上下载歌曲封面嵌入无法显示的问题
|
- 修复MAC平台上下载歌曲封面嵌入无法显示的问题
|
||||||
|
|
|
@ -284,7 +284,7 @@ export default {
|
||||||
l.sourceListId = id
|
l.sourceListId = id
|
||||||
if (!needSave) needSave = true
|
if (!needSave) needSave = true
|
||||||
})
|
})
|
||||||
if (needSave) this.this.saveUserList(userList)
|
if (needSave) this.saveUserList(userList)
|
||||||
} else {
|
} else {
|
||||||
userList = this.userList
|
userList = this.userList
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,9 @@ export default {
|
||||||
initPlayInfo() {
|
initPlayInfo() {
|
||||||
rendererInvoke(NAMES.mainWindow.get_data, 'playInfo').then(info => {
|
rendererInvoke(NAMES.mainWindow.get_data, 'playInfo').then(info => {
|
||||||
// console.log(info, window.allList)
|
// console.log(info, window.allList)
|
||||||
|
window.restorePlayInfo = null
|
||||||
if (!info) return
|
if (!info) return
|
||||||
|
if (info.index < 0) return
|
||||||
if (info.listId) {
|
if (info.listId) {
|
||||||
const list = window.allList[info.listId]
|
const list = window.allList[info.listId]
|
||||||
// console.log(list)
|
// console.log(list)
|
||||||
|
|
|
@ -244,9 +244,28 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
changePlay(n) {
|
changePlay(n) {
|
||||||
if (!n) return
|
if (!n) return
|
||||||
|
this.resetChangePlay()
|
||||||
|
if (window.restorePlayInfo) {
|
||||||
|
let musicInfo = this.targetSong = this.list[window.restorePlayInfo.index]
|
||||||
|
this.musicInfo.songmid = musicInfo.songmid
|
||||||
|
this.musicInfo.singer = musicInfo.singer
|
||||||
|
this.musicInfo.name = musicInfo.name
|
||||||
|
this.musicInfo.album = musicInfo.albumName
|
||||||
|
this.setImg(musicInfo)
|
||||||
|
this.setLrc(musicInfo)
|
||||||
|
this.nowPlayTime = this.restorePlayTime = window.restorePlayInfo.time
|
||||||
|
this.maxPlayTime = window.restorePlayInfo.maxTime || 0
|
||||||
|
this.handleUpdateWinLyricInfo('music_info', {
|
||||||
|
songmid: this.musicInfo.songmid,
|
||||||
|
singer: this.musicInfo.singer,
|
||||||
|
name: this.musicInfo.name,
|
||||||
|
album: this.musicInfo.album,
|
||||||
|
})
|
||||||
|
window.restorePlayInfo = null
|
||||||
|
return
|
||||||
|
}
|
||||||
// console.log('changePlay')
|
// console.log('changePlay')
|
||||||
this.handleRemoveMusic()
|
this.handleRemoveMusic()
|
||||||
this.resetChangePlay()
|
|
||||||
if (this.playIndex < 0) return
|
if (this.playIndex < 0) return
|
||||||
this.stopPlay()
|
this.stopPlay()
|
||||||
this.play()
|
this.play()
|
||||||
|
@ -295,6 +314,7 @@ export default {
|
||||||
if (Math.abs(n - o) > 2) this.isActiveTransition = true
|
if (Math.abs(n - o) > 2) this.isActiveTransition = true
|
||||||
this.savePlayInfo({
|
this.savePlayInfo({
|
||||||
time: n,
|
time: n,
|
||||||
|
maxTime: this.maxPlayTime,
|
||||||
listId: this.listId,
|
listId: this.listId,
|
||||||
list: this.listId == null ? this.list : null,
|
list: this.listId == null ? this.list : null,
|
||||||
index: this.playIndex,
|
index: this.playIndex,
|
||||||
|
@ -377,12 +397,7 @@ export default {
|
||||||
this.clearLoadingTimeout()
|
this.clearLoadingTimeout()
|
||||||
this.status = this.statusText = this.$t('core.player.loading')
|
this.status = this.statusText = this.$t('core.player.loading')
|
||||||
this.maxPlayTime = audio.duration
|
this.maxPlayTime = audio.duration
|
||||||
if (window.restorePlayInfo) {
|
if (this.restorePlayTime) {
|
||||||
audio.currentTime = window.restorePlayInfo.time
|
|
||||||
window.restorePlayInfo = null
|
|
||||||
audio.pause()
|
|
||||||
this.stopPlay()
|
|
||||||
} else if (this.restorePlayTime) {
|
|
||||||
audio.currentTime = this.restorePlayTime
|
audio.currentTime = this.restorePlayTime
|
||||||
this.restorePlayTime = 0
|
this.restorePlayTime = 0
|
||||||
}
|
}
|
||||||
|
@ -651,7 +666,13 @@ export default {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
togglePlay() {
|
togglePlay() {
|
||||||
if (!audio.src) return
|
if (!audio.src) {
|
||||||
|
if (this.restorePlayTime != null) {
|
||||||
|
if (!this.assertApiSupport(this.targetSong.source)) return this.handleNext()
|
||||||
|
this.setUrl(this.targetSong)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.isPlay) {
|
if (this.isPlay) {
|
||||||
audio.pause()
|
audio.pause()
|
||||||
this.clearBufferTimeout()
|
this.clearBufferTimeout()
|
||||||
|
|
|
@ -9,6 +9,15 @@ for (const source of music.sources) {
|
||||||
sources.push(source)
|
sources.push(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filterList = list => {
|
||||||
|
const keys = new Set()
|
||||||
|
return list.filter(item => {
|
||||||
|
if (keys.has(item.songmid)) return false
|
||||||
|
keys.add(item.songmid)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// state
|
// state
|
||||||
const state = {
|
const state = {
|
||||||
tags: {},
|
tags: {},
|
||||||
|
@ -78,7 +87,7 @@ const actions = {
|
||||||
return (
|
return (
|
||||||
cache.has(key)
|
cache.has(key)
|
||||||
? Promise.resolve(cache.get(key))
|
? Promise.resolve(cache.get(key))
|
||||||
: music[source].songList.getListDetail(id, page)
|
: music[source].songList.getListDetail(id, page).then(result => ({ ...result, list: filterList(result.list) }))
|
||||||
).then(result => commit('setListDetail', { result, key, source, id, page }))
|
).then(result => commit('setListDetail', { result, key, source, id, page }))
|
||||||
},
|
},
|
||||||
getListDetailAll({ state, rootState }, { source, id }) {
|
getListDetailAll({ state, rootState }, { source, id }) {
|
||||||
|
@ -93,7 +102,7 @@ const actions = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return loadData(id, 1).then(result => {
|
return loadData(id, 1).then(result => {
|
||||||
if (result.total <= result.limit) return result.list
|
if (result.total <= result.limit) return filterList(result.list)
|
||||||
|
|
||||||
let maxPage = Math.ceil(result.total / result.limit)
|
let maxPage = Math.ceil(result.total / result.limit)
|
||||||
const loadDetail = (loadPage = 1) => {
|
const loadDetail = (loadPage = 1) => {
|
||||||
|
@ -101,7 +110,7 @@ const actions = {
|
||||||
? loadData(id, ++loadPage).then(result => result.list)
|
? loadData(id, ++loadPage).then(result => result.list)
|
||||||
: loadData(id, ++loadPage).then(result1 => loadDetail(loadPage).then(result2 => [...result1.list, ...result2]))
|
: loadData(id, ++loadPage).then(result1 => loadDetail(loadPage).then(result2 => [...result1.list, ...result2]))
|
||||||
}
|
}
|
||||||
return loadDetail().then(result2 => [...result.list, ...result2])
|
return loadDetail().then(result2 => [...result.list, ...result2]).then(list => filterList(list))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue