All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zopen.aliyun.vod.service.AliyunVodMediaService Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.zopen.aliyun.vod.service;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.vod.model.v20170321.GetVideoInfoRequest;
import com.aliyuncs.vod.model.v20170321.GetVideoInfoResponse;
import com.zopen.aliyun.exception.AliyunAssert;
import com.zopen.aliyun.exception.AliyunException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("atoAliyunVodMediaService")
public class AliyunVodMediaService {

    private static final Logger logger = LoggerFactory.getLogger(AliyunVodMediaService.class);

    @Autowired
    private DefaultAcsClient client;

    /**
     * 获取视频信息
     *
     * @param videoId 视频ID
     * @return 视频信息:https://help.aliyun.com/document_detail/52839.html?spm=a2c4g.11186623.2.17.7ebc2d52IPqrVa#Video
     */
    public GetVideoInfoResponse.Video getVideoInfo(String videoId) {
        AliyunAssert.notNullAndEmpty(videoId, "videoId 不能为空");
        GetVideoInfoRequest request = new GetVideoInfoRequest();
        request.setVideoId(videoId);
        try {
            logger.debug(">>发起获取视频信息请求:videoId[{}]", videoId);
            GetVideoInfoResponse response = client.getAcsResponse(request);
            GetVideoInfoResponse.Video video = response.getVideo();
            logger.debug("<<获取获取视频信息成功");
            return video;
        } catch (Exception e) {
            logger.error("<<获取视频信息失败:" + e.getMessage(), e);
            throw new AliyunException("获取视频信息失败:" + e.getMessage());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy