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.

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

var templateConfig = {
    // 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.
    SnapshotType: 'SpriteSnapshot',
    // Specifies the normal snapshot configuration, which is shared with the original sprite snapshot configuration.
    SnapshotConfig:{
        Count: '50',
        Interval: '1',
        SpecifiedOffsetTime: '0',
        Width: '200',
        Height: '200',
        FrameType: 'normal',
        // Specifies the sprite snapshot configuration, which must be constructed based on the normal snapshot configuration.
        SpriteSnapshotConfig:{
            CellWidth: '120',
            CellHeight: '68',
            Columns: '3',
            Lines: '10',
            Padding: '20',
            Margin: '50',
            KeepCellPic: 'keep',
            Color: 'tomato'
        }
    }
};
client.request("AddVodTemplate", {
    Name: 'AddVodTemplate test', // Sets the template name.
    TemplateType: 'Snapshot', // Sets the template type to Snapshot.
    TemplateConfig: JSON.stringify(templateConfig) // Generates the snapshot template configuration.
}, {}).then(function (response) {
    // The snapshot template ID.
    console.log('SnapshotVodTemplateId = ' + response.VodTemplateId);
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Modify a snapshot template

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

var templateConfig = {
    // 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.
    SnapshotType: 'SpriteSnapshot',
    // Specifies the normal snapshot configuration, which is shared with the original sprite snapshot configuration.
    SnapshotConfig:{
        Count: '50',
        Interval: '1',
        SpecifiedOffsetTime: '0',
        Width: '200',
        Height: '200',
        FrameType: 'normal',
        // Specifies the sprite snapshot configuration, which must be constructed based on the normal snapshot configuration.
        SpriteSnapshotConfig:{
            CellWidth: '120',
            CellHeight: '68',
            Columns: '3',
            Lines: '10',
            Padding: '20',
            Margin: '50',
            KeepCellPic: 'keep',
            Color: 'tomato'
        }
    }
};
client.request("UpdateVodTemplate", {
    VodTemplateId: 'VodTemplateId', // Specifies the ID of the template to be modified.
    Name: 'UpdateVodTemplate test', // Sets the template name.
    TemplateConfig: JSON.stringify(templateConfig) // Generates the snapshot template configuration.
}, {}).then(function (response) {
    // The snapshot template ID.
    console.log('SnapshotVodTemplateId = ' + response.VodTemplateId);
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Delete a snapshot template

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("DeleteVodTemplate", {
    VodTemplateId: 'VodTemplateId' // Specifies the ID of the template to be deleted.
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Query a list of snapshot templates

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("ListVodTemplate", {
    TemplateType: 'Snapshot' // Sets the template type to Snapshot.
}, {}).then(function (response) {
    // The number of templates that are found.
    console.log('SnapshotVodTemplate Count = ' + response.VodTemplateInfoList.length);
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Query a snapshot template

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("GetVodTemplate", {
    VodTemplateId: 'VodTemplateId' // Specifies the ID of the template to be queried.
}, {}).then(function (response) {
    // The returned snapshot template ID.
    if (response.VodTemplateInfo){
        console.log('SnapshotVodTemplateId = ' + response.VodTemplateInfo.VodTemplateId);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});