新增播放错误时自动切换歌曲设置

pull/930/merge
lyswhut 2022-03-25 15:52:33 +08:00
parent 1f97af6ff1
commit 9fd9449eca
10 changed files with 28 additions and 11 deletions

View File

@ -2,6 +2,7 @@
- 新增播放详情页歌词右键菜单,原来设置-播放详情页设置的字体重置已迁移到此菜单内
- 新增歌词偏移设置,可以在播放详情页歌词右键菜单中使用
- 新增设置-播放设置-播放错误时自动切换歌曲设置默认开启原来的行为若你不想在遇到音频加载失败、url获取失败等错误时自动切歌可以关闭此设置
### 修复

View File

@ -2,7 +2,7 @@ const path = require('path')
const os = require('os')
const defaultSetting = {
version: '1.0.54',
version: '1.0.55',
player: {
togglePlayMethod: 'listLoop',
highQuality: false,
@ -18,6 +18,7 @@ const defaultSetting = {
audioVisualization: false,
waitPlayEndStop: true,
waitPlayEndStopTime: '',
autoSkipOnError: true,
},
playDetail: {
isZoomActiveLrc: true,

View File

@ -338,6 +338,7 @@
"setting__other_tray_theme_native": "White",
"setting__other_tray_theme_origin": "Primary Color",
"setting__play": "Play",
"setting__play_auto_skip_on_error": "Automatically switch songs on playback error",
"setting__play_detail": "Play details page settings",
"setting__play_detail_align": "Lyric Alignment",
"setting__play_detail_align_center": "Centered",

View File

@ -338,16 +338,17 @@
"setting__other_tray_theme_native": "白色",
"setting__other_tray_theme_origin": "原色",
"setting__play": "播放设置",
"setting__play_auto_skip_on_error": "播放错误时自动切换歌曲",
"setting__play_detail": "播放详情页设置",
"setting__play_detail_align": "歌词对齐方式",
"setting__play_detail_align_center": "居中",
"setting__play_detail_align_left": "居左",
"setting__play_detail_align_right": "居右",
"setting__play_detail_lyric_progress": "允许通过歌词调整播放进度",
"setting__play_detail_font_size": "歌词字体大小(可以在播放详情页使用键盘的 + - 调整字体大小)",
"setting__play_detail_font_size_current": "当前字体大小:{size}",
"setting__play_detail_font_size_reset": "重置",
"setting__play_detail_font_zoom": "缩放当前正在播放的歌词",
"setting__play_detail_lyric_progress": "允许通过歌词调整播放进度",
"setting__play_lyric_lxlrc": "使用卡拉OK式歌词播放如果支持",
"setting__play_lyric_s2t": "将播放与下载的歌词转换为繁体中文",
"setting__play_lyric_transition": "显示歌词翻译",

View File

@ -338,16 +338,17 @@
"setting__other_tray_theme_native": "白色",
"setting__other_tray_theme_origin": "原色",
"setting__play": "播放設置",
"setting__play_auto_skip_on_error": "播放錯誤時自動切換歌曲",
"setting__play_detail": "播放詳情頁設置",
"setting__play_detail_align": "歌詞對齊方式",
"setting__play_detail_align_center": "居中",
"setting__play_detail_align_left": "居左",
"setting__play_detail_align_right": "居右",
"setting__play_detail_lyric_progress": "允許通過歌詞調整播放進度",
"setting__play_detail_font_size": "歌詞字體大小(可以在播放詳情頁使用鍵盤的 + - 調整字體大小)",
"setting__play_detail_font_size_current": "當前字體大小:{size}",
"setting__play_detail_font_size_reset": "重置",
"setting__play_detail_font_zoom": "縮放當前正在播放的歌詞",
"setting__play_detail_lyric_progress": "允許通過歌詞調整播放進度",
"setting__play_lyric_lxlrc": "使用卡拉OK式歌詞播放如果支持",
"setting__play_lyric_s2t": "將播放與下載的歌詞轉換為繁體中文",
"setting__play_lyric_transition": "顯示歌詞翻譯",

View File

@ -2,8 +2,10 @@ import { onBeforeUnmount, useI18n } from '@renderer/utils/vueTools'
import { player as eventPlayerNames } from '@renderer/event/names'
import { wait, waitCancel } from '@renderer/utils/tools'
import { musicInfo, musicInfoItem, playMusicInfo } from '@renderer/core/share/player'
import { setStop, isEmpty } from '@renderer/plugins/player'
export default ({
setting,
playNext,
setAllStatus,
setUrl,
@ -50,7 +52,7 @@ export default ({
const handleLoadstart = () => {
if (global.isPlayedStop) return
startLoadingTimeout()
if (setting.value.player.autoSkipOnError) startLoadingTimeout()
setAllStatus(t('player__loading'))
}
@ -79,6 +81,7 @@ export default ({
if (!musicInfo.songmid) return
clearLoadingTimeout()
if (global.isPlayedStop) return
if (!isEmpty()) setStop()
if (playMusicInfo.listId != 'download' && errCode !== 1 && retryNum < 2) { // 若音频URL无效则尝试刷新2次URL
// console.log(this.retryNum)
retryNum++
@ -87,8 +90,10 @@ export default ({
return
}
setAllStatus(t('player__error'))
addDelayNextTimeout()
if (setting.value.player.autoSkipOnError) {
setAllStatus(t('player__error'))
addDelayNextTimeout()
}
}
const handleSetPlayInfo = () => {

View File

@ -31,7 +31,7 @@ export default ({ setting, playNext }) => {
if (skipTime > playProgress.maxPlayTime) skipTime = (playProgress.maxPlayTime - currentTime) / 2
if (skipTime - mediaBuffer.playTime < 1 || playProgress.maxPlayTime - skipTime < 1) {
mediaBuffer.playTime = 0
playNext()
if (setting.value.player.autoSkipOnError) playNext()
return
}
startBuffering()

View File

@ -87,12 +87,14 @@ export default ({ setting }) => {
const { addDelayNextTimeout, clearDelayNextTimeout } = useDelayNextTimeout({ playNext, timeout: 5000 })
const { addDelayNextTimeout: addLoadTimeout, clearDelayNextTimeout: clearLoadTimeout } = useDelayNextTimeout({ playNext, timeout: 123000 })
let isGettingUrl = false
const setUrl = (targetSong, isRefresh, isRetryed = false) => {
let type = getPlayType(setting.value.player.highQuality, targetSong)
// this.musicInfo.url = await getMusicUrl(targetSong, type)
setAllStatus(t('player__geting_url'))
addLoadTimeout()
if (setting.value.player.autoSkipOnError) addLoadTimeout()
isGettingUrl = true
return getUrl({
musicInfo: targetSong,
type,
@ -113,10 +115,11 @@ export default ({ setting }) => {
if (err.message == requestMsg.cancelRequest) return
if (!isRetryed) return setUrl(targetSong, isRefresh, true)
setAllStatus(err.message)
addDelayNextTimeout()
if (setting.value.player.autoSkipOnError) addDelayNextTimeout()
return Promise.reject(err)
}).finally(() => {
clearLoadTimeout()
if (targetSong === musicInfoItem.value) isGettingUrl = false
})
}
const setImg = ({ listId, musicInfo: targetSong }) => {
@ -162,6 +165,7 @@ export default ({ setting }) => {
usePlayProgress({ setting, playNext })
useMediaSessionInfo({ playPrev, playNext })
usePlayEvent({
setting,
playNext,
setAllStatus,
setUrl,
@ -313,10 +317,10 @@ export default ({ setting }) => {
}
return
}
setResource(filePath)
if (!isGettingUrl) setResource(filePath)
} else {
// if (!this.assertApiSupport(this.targetSong.source)) return this.playNext()
setUrl(musicInfoItem.value)
if (!isGettingUrl) setUrl(musicInfoItem.value)
}
return
}

View File

@ -5,6 +5,8 @@ dd
base-checkbox(id="setting_player_save_play_time" v-model="currentStting.player.isSavePlayTime" :label="$t('setting__play_save_play_time')")
.gap-top
base-checkbox(id="setting_player_lyric_transition" v-model="currentStting.player.isShowLyricTranslation" :label="$t('setting__play_lyric_transition')")
.gap-top
base-checkbox(id="setting_player_auto_skip_on_error" v-model="currentStting.player.autoSkipOnError" :label="$t('setting__play_auto_skip_on_error')")
.gap-top
base-checkbox(id="setting_player_lyric_s2t" v-model="currentStting.player.isS2t" :label="$t('setting__play_lyric_s2t')")
.gap-top

View File

@ -16,6 +16,7 @@ export const currentStting = ref({
audioVisualization: false,
waitPlayEndStop: true,
waitPlayEndStopTime: '',
autoSkipOnError: true,
},
playDetail: {
isZoomActiveLrc: true,