Files
nuttyreading-java/src/main/java/com/peanut/common/service/AsyncService.java
wangjinlei 7beb2b2b2c bug
2024-05-16 13:54:42 +08:00

30 lines
1.4 KiB
Java

package com.peanut.common.service;
import com.aliyun.vod20170321.models.GetVideoPlayAuthResponse;
import com.peanut.common.utils.SpdbUtil;
import com.peanut.modules.common.dao.CourseCatalogueChapterVideoDao;
import com.peanut.modules.common.entity.CourseCatalogueChapterVideoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@Service
public class AsyncService {
@Autowired
private CourseCatalogueChapterVideoDao courseCatalogueChapterVideoDao;
@Async
public void pushDurationToVideo(Integer videoId) throws Exception {
CourseCatalogueChapterVideoEntity courseCatalogueChapterVideoEntity = courseCatalogueChapterVideoDao.selectById(videoId);
if(courseCatalogueChapterVideoEntity.getType()==1){
GetVideoPlayAuthResponse p = SpdbUtil.getPlayAuth(courseCatalogueChapterVideoEntity.getVideo());
int i = p.getBody().getVideoMeta().getDuration().intValue();
courseCatalogueChapterVideoEntity.setDuration(i);
}else{
// Integer mp4Duration = SpdbUtil.getMp4Duration("https://ehh-private-01.oss-cn-beijing.aliyuncs.com/video/taiHuClass/" + courseCatalogueChapterVideoEntity.getVideo());
// courseCatalogueChapterVideoEntity.setDuration(mp4Duration);
}
courseCatalogueChapterVideoDao.updateById(courseCatalogueChapterVideoEntity);
}
}