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.

/**
 * Method for constructing the configuration of a snapshot template. Modify parameters as required.
 * (The following sample code shows the complete sprite snapshot configuration.)
 * @return
 */
function buildSnapshotTemplateConfig() {
    $templateConfig = array();

    // Specifies the normal snapshot configuration, which is shared with the original sprite snapshot configuration.
    $snapshotConfig = array();
    $snapshotConfig["Count"] = "50";
    $snapshotConfig["Interval"] = "1";
    $snapshotConfig["SpecifiedOffsetTime"] = "0";
    $snapshotConfig["Width"] = "200";
    $snapshotConfig["Height"] = "200";
    $snapshotConfig["FrameType"] = "normal";
    $templateConfig["SnapshotConfig"] = $snapshotConfig;

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

    // 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 json_encode($templateConfig);
}

/**
 * Method for adding a snapshot template
 */
function addSnapshotVodTemplate($client) {
    $request = new vod\AddVodTemplateRequest();
    // Sets the template name.
    $request->setName("AddVodTemplate test");
    // Sets the template type to Snapshot.
    $request->setTemplateType("Snapshot");
    // Generates the snapshot template configuration.
    $request->setTemplateConfig(buildSnapshotTemplateConfig());

    return $client->getAcsResponse($request);
}

/**
 * Call example
 */
try {
    $client = initVodClient("<AccessKeyId>", "<AccessKeySecret>");

    $result = addSnapshotVodTemplate($client);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Modify a snapshot template

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

/**
 * Method for constructing the configuration of a snapshot template. Modify parameters as required.
 * (The following sample code shows the complete normal snapshot configuration.)
 * @return
 */
function buildSnapshotTemplateConfig() {
    $templateConfig = array();

    // Specifies the normal snapshot configuration, which is shared with the original sprite snapshot configuration.
    $snapshotConfig = array();
    $snapshotConfig["Count"] = "50";
    $snapshotConfig["Interval"] = "1";
    $snapshotConfig["SpecifiedOffsetTime"] = "0";
    $snapshotConfig["Width"] = "200";
    $snapshotConfig["Height"] = "200";
    $snapshotConfig["FrameType"] = "normal";
    $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"] = "NormalSnapshot";

    return json_encode($templateConfig);
}

/**
 * Method for modifying a snapshot template
 */
function updateSnapshotVodTemplate($client) {
    $request = new vod\UpdateVodTemplateRequest();
    // Specifies the ID of the template to be modified.
    $request->setVodTemplateId("6e9835ce8896aa3ace027c0483xxxxx");
    // Sets the template name.
    $request->setName("UpdateVodTemplate test");
    // Generates the snapshot template configuration.
    $request->setTemplateConfig(buildSnapshotTemplateConfig());

    return $client->getAcsResponse($request);
}


/**
 * Call example
 */
try {
    $client = initVodClient("<AccessKeyId>", "<AccessKeySecret>"); 

    $result = updateSnapshotVodTemplate($client);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Delete a snapshot template

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

/**
 * Method for deleting a snapshot template
 */
function deleteSnapshotVodTemplate($client) {
    $request = new vod\DeleteVodTemplateRequest();
    // Specifies the ID of the template to be deleted.
    $request->setVodTemplateId("6e9835ce8896aa3ace027c0483xxxxxx");

    return $client->getAcsResponse($request);
}


/**
 * Call example
 */
try {
    $client = initVodClient("<AccessKeyId>", "<AccessKeySecret>");

    $result = deleteSnapshotVodTemplate($client);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Query a list of snapshot templates

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

/**
 * Method for querying a list of snapshot templates
 */
function listSnapshotVodTemplate($client) {
    $request = new vod\ListVodTemplateRequest();
    // Sets the template type to Snapshot.
    $request->setTemplateType("Snapshot");

    return $client->getAcsResponse($request);
}


/**
 * Call example
 */
try {
    $client = initVodClient("<AccessKeyId>", "<AccessKeySecret>");

    $result = listSnapshotVodTemplate($client);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

Query a snapshot template

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

/**
 * Method for querying a snapshot template
 */
function getSnapshotVodTemplate($client) {
    $request = new vod\GetVodTemplateRequest();
    // Specifies the ID of the template to be queried.
    $request->setVodTemplateId("6e9835ce8896aa3ace027c0483xxxxxx");

    return $client->getAcsResponse($request);
}


/**
 * Call example
 */
try {
    $client = initVodClient("<AccessKeyId>", "<AccessKeySecret>");

    $result = getSnapshotVodTemplate($client);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}