整合阿里云视频点播服务测试

一、安装SDK

1、配置pom

...

2、安装非开源jar包

在本地Maven仓库中安装jar包: 下载视频上传SDK,解压,命令行进入lib目录,执行以下代码
mvn install:install-file -DgroupId=com.aliyun -DartifactId=aliyun-sdk-vod-upload -Dversion=1.4.11 -Dpackaging=jar -Dfile=aliyun-java-vod-upload-1.4.11.jar//注意:这里的DartifactId是错误的!正确的是 -DartifactId=aliyun-java-vod-upload
然后在pom中引入jar包
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-sdk-vod-upload</artifactId>
    <version>1.4.11</version>
</dependency>

二、测试

1、创建测试文件

public class InitObject {
    public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException {
        String regionId = "cn-shanghai";  // 点播服务接入区域
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }
}

2.获取播放凭证

public class TestVideo {
    public static void main(String[] args) throws Exception {
       // getVideoUrl();
        getPlayAuth();

    }

    public static void getVideoUrl() throws ClientException {
        DefaultAcsClient client=InitObject.initVodClient("LTAI4..........1rEw3UHi","cMFEuiQNmd73............OBQoDOKG");
        GetPlayInfoRequest request = new GetPlayInfoRequest();
        GetPlayInfoResponse response = new GetPlayInfoResponse();


        request.setVideoId("b60cf23a2338431a855b44001a2ac8fb");
        response= client.getAcsResponse(request);
        List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList();
        //播放地址
        for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) {
            System.out.print("PlayInfo.PlayURL = " + playInfo.getPlayURL() + "\n");
        }
        //Base信息
        System.out.print("VideoBase.Title = " + response.getVideoBase().getTitle() + "\n");


    }




    //1 根据视频iD获取视频播放凭证
    public static void getPlayAuth() throws Exception{

        DefaultAcsClient client = InitObject.initVodClient("LTAI4FyKCNK4Rfc21rEw3UHi", "cMFEuiQNmd738Eg7c7qqleOBQoDOKG");

        GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
        GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();

        request.setVideoId("d9c6ebe8a4ce424e89e524b8614146ac");

        response = client.getAcsResponse(request);
        System.out.println("playAuth:"+response.getPlayAuth());
    }

}

 

上一篇:一个基于multiprocessing的Server-Client实例


下一篇:hive函数大全