| @@ -255,34 +255,38 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | ||||
| videoUpd.setId(mouldVideo.getId()); | videoUpd.setId(mouldVideo.getId()); | ||||
| videoUpd.setVideoId(result.getVideoId()); | videoUpd.setVideoId(result.getVideoId()); | ||||
| videoUpd.setVideoPlayUrl(url); | |||||
| videoUpd.setCoverImg(result.getCoverURL()); | |||||
| videoUpd.setVideoPlayUrl(result.getVideoUrl()); | |||||
| videoUpd.setVideoTime(result.getDuration()); | |||||
| videoUpd.setVideoSize(result.getSize()); | |||||
| videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | ||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| AtomicInteger integer = new AtomicInteger(30); | AtomicInteger integer = new AtomicInteger(30); | ||||
| while (true){ | while (true){ | ||||
| String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); | |||||
| try { | try { | ||||
| String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); | |||||
| Thread.sleep(1000); | Thread.sleep(1000); | ||||
| if (progress.equals("complete")) { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId()); | |||||
| if (videoDetail.isSuccess() | |||||
| && StringUtils.isNotBlank(videoDetail.getDuration()) | |||||
| && !"0.0".equals(videoDetail.getDuration())) { | |||||
| mouldVideo.setCoverImg(videoDetail.getCoverURL()); | |||||
| mouldVideo.setVideoPlayUrl(videoDetail.getVideoUrl()); | |||||
| mouldVideo.setVideoTime(videoDetail.getDuration()); | |||||
| mouldVideo.setVideoSize(videoDetail.getSize()); | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (integer.getAndDecrement() <= 0){ | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
| throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
| } | } | ||||
| if (progress.equals("complete")) { | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| if (integer.getAndDecrement() <= 0){ | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||