Day09-根据视频id获取视频url、视频凭证-p141、142

com.aliyun.oss

aliyun-sdk-oss

com.aliyun

aliyun-java-sdk-vod

com.aliyun

aliyun-sdk-vod-upload

com.alibaba

fastjson

org.json

json

com.google.code.gson

gson

joda-time

joda-time

2、初始化操作,创建DefaultAcsClient对象

===========================================================================================

在这里插入图片描述

package com.nonglin.vodtest;

import com.aliyun.oss.ClientException;

import com.aliyuncs.DefaultAcsClient;

import com.aliyuncs.profile.DefaultProfile;

/**

  • @Description :

  • @Author :lenovo

  • @Date :2021/3/23 17:26

*/

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;

}

}

3、根据视频id获取视频url,视频凭证

===================================================================================

在这里插入图片描述

package com.nonglin.vodtest;

import com.aliyuncs.DefaultAcsClient;

import com.aliyuncs.exceptions.ClientException;

import com.aliyuncs.vod.model.v20170321.*;

import java.sql.SQLOutput;

import java.util.List;

/**

  • @Description :

  • @Author :lenovo

  • @Date :2021/3/23 17:39

*/

public class TestVod {

//根据视频id获取播放凭证

public static void getPlayAuth() throws Exception {

//创建初始化对象

DefaultAcsClient client = InitObject.initVodClient(“LTAI4G2yRPYsosG3dhQcYWwF”,“Sdy6TvKpxflG6XvpZe5I0ZKERTCWeB”);

//创建获取视频凭证request和response

GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();

GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();

//向request设置视频id

request.setVideoId(“70706271f0f349a68e6e6f1648a68c46”);

//调用初始化对象的方法得到凭证

response = client.getAcsResponse(request);

System.out.println(“视频凭证:”+response.getPlayAuth());

}

//根据视频ID获取视频播放地址

public static void getUrl() throws Exception {

//创建初始化对象

DefaultAcsClient client = InitObject.initVodClient(“LTAI4G2yRPYsosG3dhQcYWwF”,“Sdy6TvKpxflG6XvpZe5I0ZKERTCWeB”);

//创建获取视频地址request和response

GetPlayInfoRequest request = new GetPlayInfoRequest();

GetPlayInfoResponse response = new GetPlayInfoResponse();

//向request对象里面设置视频id

request.setVideoId(“70706271f0f349a68e6e6f1648a68c46”);

//调用初始化对象里面的方法,传递request,获取数据

response = client.getAcsResponse(request);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值