From 9fd9449ecadffaf811eea26f2839554efee7aa26 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 25 Mar 2022 15:52:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=92=AD=E6=94=BE=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=B6=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/common/defaultSetting.js | 3 ++- src/lang/en-us.json | 1 + src/lang/zh-cn.json | 3 ++- src/lang/zh-tw.json | 3 ++- src/renderer/core/useApp/usePlayer/usePlayEvent.js | 11 ++++++++--- .../core/useApp/usePlayer/usePlayProgress.js | 2 +- src/renderer/core/useApp/usePlayer/usePlayer.js | 12 ++++++++---- .../views/setting/components/SettingPlay.vue | 2 ++ src/renderer/views/setting/setting.js | 1 + 10 files changed, 28 insertions(+), 11 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 160dfa70..372568ea 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,6 +2,7 @@ - 新增播放详情页歌词右键菜单,原来设置-播放详情页设置的字体重置已迁移到此菜单内 - 新增歌词偏移设置,可以在播放详情页歌词右键菜单中使用 +- 新增设置-播放设置-播放错误时自动切换歌曲设置,默认开启(原来的行为),若你不想在遇到音频加载失败、url获取失败等错误时自动切歌可以关闭此设置 ### 修复 diff --git a/src/common/defaultSetting.js b/src/common/defaultSetting.js index 6e075811..15d75e44 100644 --- a/src/common/defaultSetting.js +++ b/src/common/defaultSetting.js @@ -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, diff --git a/src/lang/en-us.json b/src/lang/en-us.json index 32cff940..63a800bc 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -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", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index 75b8275a..37daa6b6 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -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": "显示歌词翻译", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index 6173e370..dc8ac77b 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -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": "顯示歌詞翻譯", diff --git a/src/renderer/core/useApp/usePlayer/usePlayEvent.js b/src/renderer/core/useApp/usePlayer/usePlayEvent.js index 76f9836c..b734126b 100644 --- a/src/renderer/core/useApp/usePlayer/usePlayEvent.js +++ b/src/renderer/core/useApp/usePlayer/usePlayEvent.js @@ -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 = () => { diff --git a/src/renderer/core/useApp/usePlayer/usePlayProgress.js b/src/renderer/core/useApp/usePlayer/usePlayProgress.js index 95707e21..7c18c129 100644 --- a/src/renderer/core/useApp/usePlayer/usePlayProgress.js +++ b/src/renderer/core/useApp/usePlayer/usePlayProgress.js @@ -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() diff --git a/src/renderer/core/useApp/usePlayer/usePlayer.js b/src/renderer/core/useApp/usePlayer/usePlayer.js index 8cf56bbd..452deeda 100644 --- a/src/renderer/core/useApp/usePlayer/usePlayer.js +++ b/src/renderer/core/useApp/usePlayer/usePlayer.js @@ -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 } diff --git a/src/renderer/views/setting/components/SettingPlay.vue b/src/renderer/views/setting/components/SettingPlay.vue index d29048dd..1f6cddb6 100644 --- a/src/renderer/views/setting/components/SettingPlay.vue +++ b/src/renderer/views/setting/components/SettingPlay.vue @@ -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 diff --git a/src/renderer/views/setting/setting.js b/src/renderer/views/setting/setting.js index 4f518198..03e0361f 100644 --- a/src/renderer/views/setting/setting.js +++ b/src/renderer/views/setting/setting.js @@ -16,6 +16,7 @@ export const currentStting = ref({ audioVisualization: false, waitPlayEndStop: true, waitPlayEndStopTime: '', + autoSkipOnError: true, }, playDetail: { isZoomActiveLrc: true,