All Products
Search
Document Center

Snapshot template

Last Updated: Jul 11, 2019

Initialize a client

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

Add a snapshot template

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

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

/**
 * Method for constructing the configuration of a snapshot template. Modify parameters as required.
 * (The following sample code shows the complete sprite snapshot configuration.)
 * @return
 */
Json::Value buildSnapshotTemplateConfig() {
    Json::Value templateConfig;
    Json::Value snapshotConfig;
    snapshotConfig["Count"] = "50";
    snapshotConfig["Interval"] = "1";
    snapshotConfig["SpecifiedOffsetTime"] = "0";
    snapshotConfig["Width"] = "200";
    snapshotConfig["Height"] = "200";
    snapshotConfig["FrameType"] = "normal";

    // Specifies the sprite snapshot configuration, which must be constructed based on the normal snapshot configuration.
    Json::Value spriteSnapshotConfig;
    spriteSnapshotConfig["CellWidth"] = "120";
    spriteSnapshotConfig["CellHeight"] = "68";
    spriteSnapshotConfig["Columns"] = "3";
    spriteSnapshotConfig["Lines"] = "10";
    spriteSnapshotConfig["Padding"] = "20";
    spriteSnapshotConfig["Margin"] = "50";
    spriteSnapshotConfig["KeepCellPic"] = "keep";
    spriteSnapshotConfig["Color"] = "tomato";
    snapshotConfig["SpriteSnapshotConfig"] = spriteSnapshotConfig;

    // Specifies the normal snapshot configuration, which is shared with the original sprite snapshot configuration.
    templateConfig["SnapshotConfig"] = snapshotConfig;

    // Sets the snapshot type. If the sprite snapshot is configured, set the value to SpriteSnapshot. If the sprite snapshot is not configured, set the value to NormalSnapshot.
    templateConfig["SnapshotType"] = "SpriteSnapshot";
    return templateConfig;
}

/**
 * Method for adding a snapshot template
 */
VodApiResponse addSnapshotVodTemplate(VodCredential authInfo) {
    string apiName = "AddVodTemplate";
    map<string, string> args;
    // Sets the template name.
    args["Name"] = "Addtest";
    // Sets the template type to Snapshot.
    args["TemplateType"] = "Snapshot";
    // Generates the snapshot template configuration.
    Json::Value templateConfig = buildSnapshotTemplateConfig();
    args["TemplateConfig"] = templateConfig.toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

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

Modify a snapshot template

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

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

/**
 * Method for constructing the configuration of a snapshot template. Modify parameters as required.
 * (The following sample code shows the complete sprite snapshot configuration.)
 * @return
 */
Json::Value buildSnapshotTemplateConfig() {
    Json::Value templateConfig;
    Json::Value snapshotConfig;
    snapshotConfig["Count"] = "50";
    snapshotConfig["Interval"] = "1";
    snapshotConfig["SpecifiedOffsetTime"] = "0";
    snapshotConfig["Width"] = "200";
    snapshotConfig["Height"] = "200";
    snapshotConfig["FrameType"] = "normal";

    // Specifies the sprite snapshot configuration, which must be constructed based on the normal snapshot configuration.
    Json::Value spriteSnapshotConfig;
    spriteSnapshotConfig["CellWidth"] = "120";
    spriteSnapshotConfig["CellHeight"] = "68";
    spriteSnapshotConfig["Columns"] = "3";
    spriteSnapshotConfig["Lines"] = "10";
    spriteSnapshotConfig["Padding"] = "20";
    spriteSnapshotConfig["Margin"] = "50";
    spriteSnapshotConfig["KeepCellPic"] = "keep";
    spriteSnapshotConfig["Color"] = "tomato";
    snapshotConfig["SpriteSnapshotConfig"] = spriteSnapshotConfig;

    // Specifies the normal snapshot configuration, which is shared with the original sprite snapshot configuration.
    templateConfig["SnapshotConfig"] = snapshotConfig;

    // Sets the snapshot type. If the sprite snapshot is configured, set the value to SpriteSnapshot. If the sprite snapshot is not configured, set the value to NormalSnapshot.
    templateConfig["SnapshotType"] = "SpriteSnapshot";
    return templateConfig;
}

/**
 * Method for modifying a snapshot template
 */
VodApiResponse updateSnapshotVodTemplate(VodCredential authInfo) {
    string apiName = "UpdateVodTemplate";
    map<string, string> args;
    // Specifies the ID of the template to be modified.
    args["VodTemplateId"] = "53azf9d796fad9d7b862b2e5e5b";
    // Sets the template name.
    args["Name"] = "updatetest";
    // Generates the snapshot template configuration.
    Json::Value templateConfig = buildSnapshotTemplateConfig();
    args["TemplateConfig"] = templateConfig.toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

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

Delete a snapshot template

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

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


/**
 * Method for deleting a snapshot template
 */
VodApiResponse deleteSnapshotVodTemplate(VodCredential authInfo) {
    string apiName = "DeleteVodTemplate";
    map<string, string> args;
    // Specifies the ID of the template to be deleted.
    args["VodTemplateId"] = "53azf9d796fad9d7b862b2e5e5b";
    return getAcsResponse(authInfo, apiName, args);
}

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

Query a list of snapshot templates

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

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

/**
 * Method for querying a list of snapshot templates
 */
VodApiResponse listSnapshotVodTemplate(VodCredential authInfo) {
    string apiName = "ListVodTemplate";
    map<string, string> args; 
    // Sets the template type to Snapshot.
    args["TemplateType"] = "Snapshot";
    return getAcsResponse(authInfo, apiName, args);
}

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

Query a snapshot template

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

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

/**
* Method for querying a snapshot template
*/
VodApiResponse getSnapshotVodTemplate(VodCredential authInfo) {
    string apiName = "GetVodTemplate";
    map<string, string> args;
    // Specifies the ID of the template to be queried.
    args["VodTemplateId"] = "53azf9d796fad9d7b862b2e5e5b";
    return getAcsResponse(authInfo, apiName, args);
}

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