标签:测试 jar request public 阿里 client aliyun 视频点播 response
一、安装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()); } }
标签:测试,jar,request,public,阿里,client,aliyun,视频点播,response
来源: https://www.cnblogs.com/upupup-999/p/15853308.html
本站声明:
1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。