添加媒体播放进度条的信息设置

pull/733/head
lyswhut 2021-11-09 09:17:21 +08:00
parent fd764a28a4
commit df20e97d60
2 changed files with 13 additions and 1 deletions

View File

@ -3,6 +3,7 @@
- 优化我的列表、下载列表等列表的滚动流畅度
- 优化下载功能的批量添加、删除、暂停任务时的流畅度,现在进行这些操作应该不会再觉得卡顿了
- 支持启动软件时恢复播放下载列表里的歌曲
- 添加媒体播放进度条的信息设置
### 修复

View File

@ -417,6 +417,8 @@ export default {
if (!this.targetSong.interval && this.listId != 'download') {
this.updateMusicInfo({ listId: this.listId, id: this.targetSong.songmid, musicInfo: this.targetSong, data: { interval: formatPlayTime2(this.maxPlayTime) } })
}
this.updatePositionState()
})
audio.addEventListener('loadstart', () => {
console.log('loadstart')
@ -431,6 +433,7 @@ export default {
audio.currentTime = playTime
}
this.clearBufferTimeout()
this.updatePositionState()
// if (this.musicInfo.lrc) window.lrc.play(audio.currentTime * 1000)
this.status = this.statusText = ''
@ -484,7 +487,6 @@ export default {
},
async play() {
this.clearDelayNextTimeout()
this.updateMediaSessionInfo()
let targetSong = this.targetSong
@ -514,6 +516,8 @@ export default {
this.musicInfo.album = targetSong.albumName
this.setUrl(targetSong)
}
this.updateMediaSessionInfo()
this.setImg(targetSong)
this.setLrc(targetSong)
this.handleUpdateWinLyricInfo('music_info', {
@ -972,6 +976,13 @@ export default {
if (this.currentMusicInfo.img) mediaMetadata.artwork = [{ src: this.currentMusicInfo.img }]
navigator.mediaSession.metadata = new window.MediaMetadata(mediaMetadata)
},
updatePositionState() {
navigator.mediaSession.setPositionState({
duration: audio.duration,
playbackRate: audio.playbackRate,
position: audio.currentTime,
})
},
registerMediaSessionHandler() {
// navigator.mediaSession.setActionHandler('play', () => {
// if (this.isPlay || !this.playMusicInfo) return