阿里雲視訊點播服務端API和SDK測試
一 準備工作
1 設定不轉碼
測試之前設定預設“不轉碼”,以節省開發成本。
2 找到子賬戶的AccessKey ID
3 給子賬戶新增授權
AliyunVODFullAccess
4 閱讀文件
服務端API
API呼叫示例參考:https://help.aliyun.com/document_detail/44435.html?spm=a2c4g.11186623.6.708.2c643d44SY21Hb
服務端SDK
SDK將API進行了進一步的封裝,使用起來更簡單方便。
二 建立和初始化專案
1 建立maven專案
Group:com.atguigu
Artifact:aliyun_vod
2 新增Maven依賴
<dependencies>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-vod</artifactId>
<version>2.15.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
3 建立測試類並初始化
參考文件:https://help.aliyun.com/document_detail/61062.html
/**
* client初始化
*
* @param accessKeyId
* @param accessKeySecret
* @return DefaultAcsClient 客戶端
*/
public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) {
String regionId = "cn-shanghai"; // 點播服務接入區域
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
return client;
}
三 建立測試用例
1 獲取視訊播放地址
參考文件:https://help.aliyun.com/document_detail/61064.html
/**
* 獲取播放地址
*/
@Test
public void testGetPlayInfo() {
// 初始化客戶端
DefaultAcsClient client = initVodClient(
"<您的AccessKeyId>",
"<您的AccessKeySecret>");
// 建立請求物件
GetPlayInfoResponse response = new GetPlayInfoResponse();
try {
// 傳送請求得到響應
response = getPlayInfo(client);
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");
} catch (Exception e) {
System.out.print("ErrorMessage = " + e.getLocalizedMessage());
}
System.out.print("RequestId = " + response.getRequestId() + "\n");
}
/**
* 功能描述:獲取播放地址函式
*
* @author cakin
* @date 2020/12/12
* @param client 客戶端
* @return GetPlayInfoResponse 播放資訊響應
*/
public static GetPlayInfoResponse getPlayInfo(DefaultAcsClient client) throws Exception {
GetPlayInfoRequest request = new GetPlayInfoRequest(); // 建立請求物件
request.setResultType("Multiple");
request.setVideoId("43d6225f1e844bdcadf6f042580614a6"); // 設定請求引數
return client.getAcsResponse(request); // 傳送請求得到響應
}
測試結果:
PlayInfo.PlayURL = http://video1.guli.shop/e9e25fa83f61418fb71767d884c41742/a67a1c2045064b13af09ffc3a45aea31-fd9af78a2f43cf04e6dbf40def56bc63-fd-encrypt-stream.m3u8
PlayInfo.PlayURL = http://video1.guli.shop/e9e25fa83f61418fb71767d884c41742/a67a1c2045064b13af09ffc3a45aea31-865fef9e41d2591d320940ae30a2bccc-ld-encrypt-stream.m3u8
VideoBase.Title = 第八章
RequestId = A83AA626-BCBB-4A11-8C4B-CBA8D376E102
2 獲取視訊播放憑證
參考文件:https://help.aliyun.com/document_detail/61064.html#h2--div-id-getvideoplayauth-div-2
加密視訊必須使用此方式播放
/**
* 獲取播放憑證
*/
@Test
public void testGetVideoPlayAuth() {
DefaultAcsClient client = initVodClient(
"LTAI4G5BTyMGDvWFjcziEGPU",
"XlKSpUcIILsdjYWuZXrRRwVbX4XlQ5");
GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();
try {
response = getVideoPlayAuth(client);
//播放憑證
System.out.print("PlayAuth = " + response.getPlayAuth() + "\n");
//VideoMeta資訊
System.out.print("VideoMeta.Title = " + response.getVideoMeta().getTitle() + "\n");
} catch (Exception e) {
System.out.print("ErrorMessage = " + e.getLocalizedMessage());
}
System.out.print("RequestId = " + response.getRequestId() + "\n");
}
/**
* 功能描述:獲取播放憑證函式
*
* @param client 客戶端
* @return GetVideoPlayAuthResponse 視訊播放授權資訊
* @author cakin
* @date 2020/12/12
* @description:
*/
public static GetVideoPlayAuthResponse getVideoPlayAuth(DefaultAcsClient client) throws Exception {
GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest(); // 建立請求物件
request.setVideoId("e9e25fa83f61418fb71767d884c41742"); // 設定請求引數
return client.getAcsResponse(request); // 傳送請求得到響應
}
測試結果
PlayAuth = eyJTZWN1cml0eV54va2VuIjoiQ0FJU2h3TjFxNkZ0NUIyeWZTaklyNWJ6Yzg3TWlleDc5Wml1Ung2RDBuUWJRdXA3blovdXFqejJJSDlJZEhWb0FPOGZ2dlUwbTJ0WTdQc1psck1xRnNVY0d4eVZNWklvdjhVR3JWci9KcExGc3QySjZyOEpqc1ViOTlCTGhsaXBzdlhKYXNEVkVmbDJFNVhFTWlJUi8wMGU2TC8rY2lyWXBUWEhWYlNDbFo5Z2FQa09Rd0M4ZGtBb0xkeEtKd3hrMnQxNFVtWFdPYVNDUHdMU2htUEJMVXhtdldnR2wyUnp1NHV5M3ZPZDVoZlpwMXI4eE80YXhlTDBQb1AyVjgxbExacGxlc3FwM0k0U2M3YmFnaFpVNGdscjhxbHg3c3BCNVN5Vmt0eVdHVWhKL3phTElvaXQ3TnBqZmlCMGVvUUFQb3BGcC9YNmp2QWF3UExVbTliWXhncGhCOFIrWGo3RFpZYXV4N0d6ZW9XVE84MCthS3p3TmxuVXo5bUxMZU9WaVE0L1ptOEJQdzQ0RUxoSWFGMElVRTF5R21DQ2QvWDRvZ3VSUDF6N0VwTG9pdjltamNCSHFIeno1c2VQS2xTMVJMR1U3RDBWSUpkVWJUbHphRUpHZ1RTNExmWldJbGNUS0FNOVd1MlBNYXgzYlFGRHI1M3ZzVGJiWHpaYjBtcHR1UG56ZDE0Sk9CS2cxMUtVR29BQlBaZTlNK20yUUE1ejkrNX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GQzWkJaRUU4MjZ0Tk5lV3JaRUgiLCJQbGF5RG9tYWluIjoidmlkZW8xLmd1bGkuc2hvcCIsIkFjY2Vzc0tleVNlY3JldCI6IkgzYURrMm1zOENrdjY1MzJDWGlabWpVdnYxQ3dMd0VhdWU5bWJHRmk2bjl5IiwiUmVnaW9uIjoiY24tc2hhbmdoYWkiLCJDdXN0b21lcklkIjoxNTIxNjg5NDEwOTk5NDE2fQ==
VideoMeta.Title = 第八章
RequestId = 7408DCE4-FC97-4C24-87EF-ACD97E50273B
相關文章
- 靠近阿里雲–視訊點播阿里
- 阿里雲視訊點播轉碼阿里
- bbossaop遠端服務介紹-點對點遠端服務呼叫和組播服務呼叫的區別
- 音視訊點播服務基礎系列(Fmpeg常用命令)
- 阿里雲視訊點播轉碼 Composer 版阿里
- YApi 服務端測試新增 globalCookie ,相容自動化觸發服務端測試功能API服務端Cookie
- 阿里雲視訊點播上傳,整合 Dcat admin阿里
- Ubuntu 中使用 Nginx+rtmp 模組搭建流媒體視訊點播服務UbuntuNginx
- SDK音訊測試流程音訊
- PC客戶端安全測試服務客戶端
- 服務端測試開發必備技能:Mock測試服務端Mock
- servlet寫服務端APIServlet服務端API
- 阿里雲簡訊服務阿里
- 效能測試-服務端瓶頸分析思路服務端
- 短視訊SDK,直播SDK,美顏SDK_提供開放API介面API
- 服務端c100k連線測試和客戶端65535測試驗證2服務端客戶端
- PHP 擴充套件包教程學習分享 -- 阿里雲簡訊服務 SDKPHP套件阿里
- 後端測試與 SDK 測試哪個前景更好?後端
- 挑戰 - 微服務架構下的服務端測試微服務架構服務端
- 主流 go-web 服務端框架效能測試GoWeb服務端框架
- 服務端效能測試你應該知道的服務端
- 【LocustPlus序】漫談服務端效能測試服務端
- 如何做好 Android 端音視訊測試?Android
- 視訊點播開發者實戰:視訊水印的基本使用
- 服務端測試很牛逼?不要慫,幹它服務端
- Python_服務端效能高併發測試Python服務端
- 某些線上點播視訊的地址格式
- Laravel 阿里雲簡訊服務包Laravel阿里
- 阿里雲訊息服務使用教程阿里
- API 和 SDKAPI
- 新一代視訊AI服務 —— 阿里雲智慧視覺重磅釋出AI阿里視覺
- 如何實現在服務端錄製視訊會議?服務端
- 直播與點播之三_測試、理解
- 一篇文章解讀阿里雲視訊點播內容安全機制阿里
- APP測試的極簡Mock方法——Mock服務端介面APPMock服務端
- [服務端] 效能測試入門指南 (慎入: 6000 字長文)服務端
- Android模組介面服務,暴露SDK+介面服務查詢(類似微信.api)AndroidAPI
- 電腦端的 API 埠測試API