修复讲解语音切换后播放器未刷新
- 暂停时切换语言或男女声同步刷新音轨、时长和进度 - 保持暂停状态,播放中继续自动切换新音轨 - 补充语音切换播放器刷新回归测试 Made-with: Proma
This commit is contained in:
@@ -205,6 +205,31 @@ const toSwitchedAudioItem = (
|
||||
supportedLanguages: currentAudio.value?.supportedLanguages
|
||||
})
|
||||
|
||||
const prepare = (audio: AudioItem, options: GlobalAudioPlayOptions = {}) => {
|
||||
const preservedMode = options.displayMode || displayMode.value
|
||||
stopAudioElement()
|
||||
currentAudio.value = audio
|
||||
currentSource.value = options.source || currentSource.value
|
||||
retryOnError = options.retryOnError || retryOnError
|
||||
visible.value = true
|
||||
displayMode.value = preservedMode
|
||||
playing.value = false
|
||||
loading.value = false
|
||||
error.value = audio.audioUrl ? '' : '当前语言暂无语音讲解'
|
||||
currentTime.value = 0
|
||||
duration.value = audio.duration || 0
|
||||
|
||||
if (audio.audioUrl) {
|
||||
const element = ensureAudioElement()
|
||||
if (element) {
|
||||
element.src = audio.audioUrl
|
||||
element.load()
|
||||
element.playbackRate = playbackRate.value
|
||||
element.muted = muted.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const play = async (audio: AudioItem, options: GlobalAudioPlayOptions = {}) => {
|
||||
if (!audio.audioUrl) {
|
||||
const preservedMode = options.displayMode || displayMode.value
|
||||
@@ -500,6 +525,7 @@ export const useGlobalAudioPlayer = () => ({
|
||||
closeVersion,
|
||||
hasAudio: computed(() => Boolean(currentAudio.value)),
|
||||
play,
|
||||
prepare,
|
||||
pause,
|
||||
resume,
|
||||
stop,
|
||||
|
||||
Reference in New Issue
Block a user