dev-v2
Joe 4 months ago
parent 6010109462
commit d68fa31ed5

@ -117,21 +117,23 @@ const AliVideoUpload: React.FC<AliVideoUploadProps> = ({
// 文件上传成功 // 文件上传成功
onUploadSucceed: (uploadInfo: any) => { onUploadSucceed: (uploadInfo: any) => {
console.log('上传成功:', uploadInfo); console.log('上传成功:', uploadInfo);
getVideoAuthByVideoIdUsingGet({ id: uploadInfo.videoId }).then(res => { setTimeout(() => {
if (res.retcode) { getVideoAuthByVideoIdUsingGet({ id: uploadInfo.videoId }).then(res => {
resolve({ if (res.retcode) {
videoId: uploadInfo.videoId, resolve({
playAuth: res.data?.playAuth, // 需要单独获取播放凭证 videoId: uploadInfo.videoId,
duration: res.data?.videoMeta?.duration, playAuth: res.data?.playAuth, // 需要单独获取播放凭证
}); duration: res.data?.videoMeta?.duration,
} else { });
message.error(res.retmsg); } else {
reject(new Error(res.retmsg)); message.error(res.retmsg);
} reject(new Error(res.retmsg));
}).catch(error => { }
message.error(error); }).catch(error => {
reject(new Error(error)); message.error(error);
}) reject(new Error(error));
})
}, 1000);
}, },
// 文件上传失败 // 文件上传失败
onUploadFailed: (uploadInfo: any, code: string, message: string) => { onUploadFailed: (uploadInfo: any, code: string, message: string) => {

@ -23,6 +23,7 @@ import { addOrUpdateChapterUsingPost, removeChapterUsingGet } from '@/services/p
import { addOrUpdateVideoUsingPost, getVideoAuthByIdUsingGet, removeVideoUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesVideoController'; import { addOrUpdateVideoUsingPost, getVideoAuthByIdUsingGet, removeVideoUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesVideoController';
import AliPlayer from '@/components/AliPlayer'; import AliPlayer from '@/components/AliPlayer';
import AliVideoUpload from '@/components/AliVideoUpload'; import AliVideoUpload from '@/components/AliVideoUpload';
import { getVideoAuthByVideoIdUsingGet } from '@/services/pop-b2b2c/pbcVodController';
/** /**
* *
@ -274,6 +275,14 @@ const Detail: React.FC<any> = () => {
); );
}; };
const getVideoDuration = async (videoId: string) => {
const res = await getVideoAuthByVideoIdUsingGet({ id: videoId })
if (res.retcode) {
return res.data?.videoMeta?.duration ? res.data?.videoMeta?.duration.toString() : ''
}
return ''
}
return ( return (
<PageContainer <PageContainer
header={{ header={{
@ -518,6 +527,9 @@ const Detail: React.FC<any> = () => {
if (value.pbcVideoAddress[0].uid === '-1') { if (value.pbcVideoAddress[0].uid === '-1') {
pbcVideoAddress = value.pbcVideoAddress[0].url || ''; pbcVideoAddress = value.pbcVideoAddress[0].url || '';
pbcVideoDuration = stepFormValues1.pbcVideoDuration || '' pbcVideoDuration = stepFormValues1.pbcVideoDuration || ''
if (!stepFormValues1.pbcVideoDuration) {
pbcVideoDuration = await getVideoDuration(value.pbcVideoAddress[0].url)
}
} }
if ( if (
value.pbcVideoAddress[0].response && value.pbcVideoAddress[0].response &&
@ -526,7 +538,10 @@ const Detail: React.FC<any> = () => {
if (fileType === '1') { if (fileType === '1') {
// 客户端上传的视频数据 // 客户端上传的视频数据
pbcVideoAddress = value.pbcVideoAddress[0].response.data.videoId; pbcVideoAddress = value.pbcVideoAddress[0].response.data.videoId;
pbcVideoDuration = value.pbcVideoAddress[0].response.data.duration || ''; pbcVideoDuration = value.pbcVideoAddress[0].response.data.duration;
if (!value.pbcVideoAddress[0].response.data.duration) {
pbcVideoDuration = await getVideoDuration(value.pbcVideoAddress[0].response.data.videoId)
}
} else { } else {
// 服务端上传的文件数据 // 服务端上传的文件数据
pbcVideoAddress = value.pbcVideoAddress[0].response.data; pbcVideoAddress = value.pbcVideoAddress[0].response.data;

Loading…
Cancel
Save