音视频播放

本篇文档提供了C/C++ SDK音视频播放模块相关功能的API调用示例。包含获取播放地址、获取视频播放凭证。

初始化客户端

使用前请先初始化客户端,请参见初始化

获取视频播放地址

调用GetPlayInfo接口,完成获取播放地址功能。

接口参数和返回字段请参见GetPlayInfo。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"

/*获取播放地址函数*/

VodApiResponse getPlayInfo(VodCredential authInfo) {
    string apiName = "GetPlayInfo";
    map<string, string> args;
    args["VideoId"] = "<VideoId>";  // 替换成需要的视频ID
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = getPlayInfo(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

获取视频播放凭证

调用GetVideoPlayAuth接口,完成获取视频播放凭证功能。

接口参数和返回字段请参见GetVideoPlayAuth。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"

/*获取播放凭证函数*/

VodApiResponse getVideoPlayAuth(VodCredential authInfo) {
    string apiName = "GetVideoPlayAuth";
    map<string, string> args;
    args["VideoId"] = "<VideoId>";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = getVideoPlayAuth(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
阿里云首页 视频点播 相关技术圈