All Products
Search
Document Center

Audio and video playback

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see initVodClient.

Obtain the audio or video playback URL

For more information about the request and response parameters, see GetPlayInfo.

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

/*Method for obtaining the audio or video playback URL*/

VodApiResponse getPlayInfo(VodCredential authInfo) {
    string apiName = "GetPlayInfo";
    map<string, string> args;
    args["VideoId"] = "<VideoId>"; // Sets the video ID.
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = getPlayInfo(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Obtain the video playback credential

For more information about the request and response parameters, see GetVideoPlayAuth.

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

/*Method for obtaining the video playback credential*/

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

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = getVideoPlayAuth(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}