30 lines
1.4 KiB
Java
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);
|
|
}
|
|
}
|