全部产品
云市场

音视频播放

更新时间:2018-12-27 21:33:26

初始化客户端

使用前请先初始化客户端,参考 initVodClient 接口。

获取视频播放地址

接口参数和返回字段请参考 GetPlayInfo

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include "vod_sdk/openApiUtil.h"
  5. /*获取播放地址函数*/
  6. VodApiResponse getPlayInfo(VodCredential authInfo) {
  7. string apiName = "GetPlayInfo";
  8. map<string, string> args;
  9. args["VideoId"] = "<VideoId>"; // 替换成需要的视频ID
  10. return getAcsResponse(authInfo, apiName, args);
  11. }
  12. // 请求示例
  13. void main() {
  14. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  15. VodApiResponse response = getPlayInfo(authInfo);
  16. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  17. }

获取视频播放凭证

接口参数和返回字段请参考 GetVideoPlayAuth

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include "vod_sdk/openApiUtil.h"
  5. /*获取播放凭证函数*/
  6. VodApiResponse getVideoPlayAuth(VodCredential authInfo) {
  7. string apiName = "GetVideoPlayAuth";
  8. map<string, string> args;
  9. args["VideoId"] = "<VideoId>";
  10. return getAcsResponse(authInfo, apiName, args);
  11. }
  12. // 请求示例
  13. void main() {
  14. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  15. VodApiResponse response = getVideoPlayAuth(authInfo);
  16. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  17. }