|
|
|
@ -321,7 +321,10 @@ export default { |
|
|
|
this.totalTime = cachedAudio.totalDuration || 0; |
|
|
|
this.hasAudioData = true; |
|
|
|
this.isAudioLoading = false; |
|
|
|
this.currentAudioIndex = 0; |
|
|
|
|
|
|
|
// 初始化音频索引为第一个非导语音频 |
|
|
|
const firstNonLeadIndex = this.findFirstNonLeadAudio(); |
|
|
|
this.currentAudioIndex = firstNonLeadIndex >= 0 ? firstNonLeadIndex : 0; |
|
|
|
this.currentTime = 0; |
|
|
|
this.currentHighlightIndex = -1; |
|
|
|
|
|
|
|
@ -612,7 +615,10 @@ export default { |
|
|
|
// 从缓存加载音频数据 |
|
|
|
this.currentPageAudios = this.audioCache[cacheKey].audios; |
|
|
|
this.totalTime = this.audioCache[cacheKey].totalDuration; |
|
|
|
this.currentAudioIndex = 0; |
|
|
|
|
|
|
|
// 初始化音频索引为第一个非导语音频 |
|
|
|
const firstNonLeadIndex = this.findFirstNonLeadAudio(); |
|
|
|
this.currentAudioIndex = firstNonLeadIndex >= 0 ? firstNonLeadIndex : 0; |
|
|
|
this.isPlaying = false; |
|
|
|
this.currentTime = 0; |
|
|
|
this.hasAudioData = true; |
|
|
|
@ -743,7 +749,10 @@ export default { |
|
|
|
if (!firstAudioPlayed && this.currentPageAudios.length > 0) { |
|
|
|
firstAudioPlayed = true; |
|
|
|
this.hasAudioData = true; |
|
|
|
this.currentAudioIndex = 0; |
|
|
|
|
|
|
|
// 初始化音频索引为第一个非导语音频 |
|
|
|
const firstNonLeadIndex = this.findFirstNonLeadAudio(); |
|
|
|
this.currentAudioIndex = firstNonLeadIndex >= 0 ? firstNonLeadIndex : 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1784,16 +1793,23 @@ export default { |
|
|
|
console.log('🎵 handlePlaybackComplete: 所有音频播放完毕'); |
|
|
|
|
|
|
|
if (this.isLoop) { |
|
|
|
// 循环播放 |
|
|
|
console.log('🎵 handlePlaybackComplete: 循环播放,重置索引为0'); |
|
|
|
this.currentAudioIndex = 0; |
|
|
|
// 循环播放 - 跳过导语音频 |
|
|
|
console.log('🎵 handlePlaybackComplete: 循环播放,查找第一个非导语音频'); |
|
|
|
const firstNonLeadIndex = this.findFirstNonLeadAudio(); |
|
|
|
|
|
|
|
// 确保第一个音频有效 |
|
|
|
const firstAudio = this.currentPageAudios[0]; |
|
|
|
if (firstAudio && firstAudio.url) { |
|
|
|
this.playAudio(); |
|
|
|
if (firstNonLeadIndex >= 0 && firstNonLeadIndex < this.currentPageAudios.length) { |
|
|
|
this.currentAudioIndex = firstNonLeadIndex; |
|
|
|
const firstAudio = this.currentPageAudios[firstNonLeadIndex]; |
|
|
|
|
|
|
|
if (firstAudio && firstAudio.url) { |
|
|
|
console.log(`🎵 handlePlaybackComplete: 循环播放从非导语音频开始,索引=${firstNonLeadIndex}, isLead=${firstAudio.isLead}`); |
|
|
|
this.playAudio(); |
|
|
|
} else { |
|
|
|
console.error('🎵 handlePlaybackComplete: 第一个非导语音频数据无效,停止循环播放'); |
|
|
|
this.stopPlayback(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.error('🎵 handlePlaybackComplete: 第一个音频数据无效,停止循环播放'); |
|
|
|
console.error('🎵 handlePlaybackComplete: 找不到有效的非导语音频,停止循环播放'); |
|
|
|
this.stopPlayback(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -2811,11 +2827,14 @@ export default { |
|
|
|
this.currentPageAudios = cachedData.audios; |
|
|
|
this.totalDuration = cachedData.totalDuration; |
|
|
|
|
|
|
|
// 重置播放状态 |
|
|
|
this.currentAudioIndex = 0; |
|
|
|
// 查找第一个非导语音频 |
|
|
|
const firstNonLeadIndex = this.findFirstNonLeadAudio(); |
|
|
|
this.currentAudioIndex = firstNonLeadIndex >= 0 ? firstNonLeadIndex : 0; |
|
|
|
this.currentTime = 0; |
|
|
|
this.isPlaying = false; |
|
|
|
|
|
|
|
console.log(`🎵 autoPlayCachedAudio: 设置起始索引为${this.currentAudioIndex}(跳过导语)`); |
|
|
|
|
|
|
|
// 延迟一下再开始播放,确保UI更新完成 |
|
|
|
setTimeout(() => { |
|
|
|
this.playAudio(); |
|
|
|
@ -2946,20 +2965,31 @@ export default { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查第一个音频是否有效 |
|
|
|
const firstAudio = this.currentPageAudios[0]; |
|
|
|
if (!firstAudio || !firstAudio.url) { |
|
|
|
// 查找第一个非导语音频 |
|
|
|
const firstNonLeadIndex = this.findFirstNonLeadAudio(); |
|
|
|
if (firstNonLeadIndex < 0 || firstNonLeadIndex >= this.currentPageAudios.length) { |
|
|
|
console.warn('🎵 autoPlayPreloadedAudio: 找不到有效的非导语音频'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const firstAudio = this.currentPageAudios[firstNonLeadIndex]; |
|
|
|
if (!firstAudio || !firstAudio.url) { |
|
|
|
console.warn('🎵 autoPlayPreloadedAudio: 第一个非导语音频数据无效'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 重置播放状态 |
|
|
|
this.currentAudioIndex = 0; |
|
|
|
// 设置播放状态(跳过导语) |
|
|
|
this.currentAudioIndex = firstNonLeadIndex; |
|
|
|
this.currentTime = 0; |
|
|
|
this.sliderValue = 0; |
|
|
|
this.currentHighlightIndex = 0; |
|
|
|
|
|
|
|
// 设置高亮索引 |
|
|
|
const highlightIndex = firstAudio.originalTextIndex !== undefined ? firstAudio.originalTextIndex : firstNonLeadIndex; |
|
|
|
this.currentHighlightIndex = highlightIndex; |
|
|
|
|
|
|
|
console.log(`🎵 autoPlayPreloadedAudio: 播放第一个非导语音频,索引=${firstNonLeadIndex}, isLead=${firstAudio.isLead}`); |
|
|
|
|
|
|
|
// 使用audioManager播放第一个音频 |
|
|
|
// 使用audioManager播放第一个非导语音频 |
|
|
|
audioManager.playAudio(firstAudio.url, 'sentence', { playbackRate: this.playSpeed }); |
|
|
|
this.isPlaying = true; |
|
|
|
|
|
|
|
|