阿里雲視訊點播服務端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
相關文章
- 靠近阿里雲–視訊點播阿里
- 阿里雲視訊點播轉碼阿里
- 阿里雲視訊點播轉碼 Composer 版阿里
- 阿里雲視訊點播上傳,整合 Dcat admin阿里
- 阿里雲簡訊服務阿里
- PHP 擴充套件包教程學習分享 -- 阿里雲簡訊服務 SDKPHP套件阿里
- 保護企業資訊保安,阿里雲滲透測試服務釋出阿里
- 音視訊點播服務基礎系列(Fmpeg常用命令)
- Laravel 阿里雲簡訊服務包Laravel阿里
- 阿里雲訊息服務使用教程阿里
- Python 服務端整合 騰訊雲 IM 服務Python服務端
- 【騰訊課堂】視訊點播上雲實踐
- 阿里雲冷門 API/SDK 對接心得阿里API
- 阿里雲簡訊傳送 sdk阿里
- 雲服務測試報告測試報告
- YApi 服務端測試新增 globalCookie ,相容自動化觸發服務端測試功能API服務端Cookie
- 新一代視訊AI服務 —— 阿里雲智慧視覺重磅釋出AI阿里視覺
- 一篇文章解讀阿里雲視訊點播內容安全機制阿里
- 騰訊雲點播 - 視訊防盜加密 - 使用總結加密
- 部署小說api服務到騰訊雲API
- 為何選擇阿里雲 簡訊服務阿里
- 阿里雲簡訊服務使用代理的坑阿里
- SDK音訊測試流程音訊
- Ubuntu 中使用 Nginx+rtmp 模組搭建流媒體視訊點播服務UbuntuNginx
- 服務端c100k連線測試和客戶端65535測試驗證2服務端客戶端
- 服務端測試開發必備技能:Mock測試服務端Mock
- 服務端測試是什麼?怎麼測?服務端
- 短視訊SDK,直播SDK,美顏SDK_提供開放API介面API
- 阿里雲ECS伺服器部署Dart服務端程式阿里伺服器Dart服務端
- 阿里雲影片點播轉碼 舊版阿里
- 廣告視訊 sdk 怎麼做自動化測試?
- 效能測試-服務端瓶頸分析思路服務端
- 後端測試與 SDK 測試哪個前景更好?後端
- API 和 SDKAPI
- 阿里雲效能測試服務 PTS 新面貌 - 壓測協議、施壓能力全新升級阿里協議
- 雲上創新,阿里雲視訊雲分享全場景音視訊服務背後的場景探索與技術實踐阿里
- 阿里雲應用高可用服務公測釋出阿里
- 阿里雲釋出 Elasticsearch 雲服務阿里Elasticsearch