| | |
| | | subtitleDialogVisible.value = true |
| | | subtitleForm.videoId = videoId |
| | | const videoDetail = await pptTemplateApi.myCourseDetail(videoId) |
| | | |
| | | |
| | | // 立即获取视频详情检查字幕状态 |
| | | subtitleForm.subtitlesAddStatus=videoDetail.subtitlesAddStatus |
| | | console.log('视频详情:', videoDetail) |
| | | if (videoDetail.subtitlesAddStatus === 2) { |
| | | subtitleForm.videoUrl = videoDetail.videoUrl || '' |
| | | generating.value=false |
| | | polling.value=false |
| | | |
| | | }else if (videoDetail.subtitlesAddStatus === 1) { |
| | | subtitleForm.videoUrl = '' |
| | | generating.value=true |
| | | polling.value=true |
| | | } |
| | |
| | | }else if (videoDetail.subtitlesStatus === 1) { |
| | | generating.value=true |
| | | polling.value=true |
| | | subtitleForm.content = '' |
| | | } |
| | | } catch (error) { |
| | | console.error('获取视频详情失败:', error) |
| | |
| | | const generateSubtitles = async () => { |
| | | try { |
| | | await subtitleFormRef.value.validateField(['timeThreshold', 'language']) |
| | | |
| | | console.log(subtitleForm) |
| | | if (!subtitleForm.videoId) { |
| | | message.warning('视频ID不能为空') |
| | | return |
| | |
| | | lang: subtitleForm.language |
| | | } |
| | | await pptTemplateApi.generateSubtitles(params) |
| | | message.success('字幕生成任务已开始') |
| | | |
| | | message.success(subtitleForm.courseName+' '+'字幕生成任务已开始') |
| | | const maxAttempts = 20000 |
| | | const interval = 3000 |
| | | let attempts = 0 |
| | |
| | | } else if (videoDetail.subtitlesContent) { |
| | | subtitleForm.content = videoDetail.subtitlesContent |
| | | } |
| | | message.success('字幕生成成功') |
| | | message.success(subtitleForm.courseName+' '+'字幕生成成功') |
| | | stopPolling() |
| | | } else if (videoDetail.subtitlesStatus === 3) { |
| | | // message.error(`字幕生成失败: ${videoDetail.errorReason || '未知原因'}`) |
| | | stopPolling() |
| | | } else if (attempts >= maxAttempts) { |
| | | message.warning('字幕生成超时,请稍后手动检查') |
| | | message.warning(subtitleForm.courseName+' '+'字幕生成超时,请稍后手动检查') |
| | | stopPolling() |
| | | } else { |
| | | pollingTimer = window.setTimeout(poll, interval) |
| | |
| | | |
| | | poll() |
| | | } catch (error) { |
| | | console.error('生成字幕出错:', error) |
| | | console.error(subtitleForm.courseName+' '+'生成字幕出错:', error) |
| | | // message.error(`生成字幕失败: ${error.message || '未知错误'}`) |
| | | stopPolling() |
| | | } finally { |
| | |
| | | id: subtitleForm.videoId |
| | | } |
| | | await pptTemplateApi.videoMeger(obj) |
| | | message.success('字幕视频合成任务已开始') |
| | | message.success(subtitleForm.courseName+' '+'字幕视频合成任务已开始') |
| | | |
| | | const maxAttempts = 200000 |
| | | const interval = 3000 |
| | |
| | | console.log('轮询字幕视频合成结果:', videoDetail) |
| | | |
| | | if (videoDetail.subtitlesAddStatus === 2) { |
| | | message.success('字幕视频合成成功') |
| | | message.success(subtitleForm.courseName+' '+'字幕视频合成成功') |
| | | if (videoDetail.previewUrl) { |
| | | subtitleForm.content = '' // 清空当前字幕内容 |
| | | stopPolling() |
| | |
| | | getList() // 刷新列表 |
| | | } |
| | | } else if (videoDetail.subtitlesAddStatus === 3) { |
| | | message.error(`字幕视频合成失败: ${videoDetail.errorReason || '未知原因'}`) |
| | | message.error(subtitleForm.courseName+' '+`字幕视频合成失败: ${videoDetail.errorReason || '未知原因'}`) |
| | | stopPolling() |
| | | } else if (attempts >= maxAttempts) { |
| | | message.warning('字幕视频合成超时,请稍后手动检查') |
| | | message.warning(subtitleForm.courseName+' '+'字幕视频合成超时,请稍后手动检查') |
| | | stopPolling() |
| | | } else { |
| | | pollingTimer = window.setTimeout(poll, interval) |