全部产品
云市场

截图模板

更新时间:2019-01-17 13:55:02

初始化客户端

使用前请先初始化客户端,参考 initVodClient 接口。

添加截图模板

接口参数和返回字段请参考 AddVodTemplate

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 构建截图模板的配置数据,根据具体设置需求修改对应的参数值
  8. * (以下代码示例为雪碧图完整配置)
  9. * @return
  10. */
  11. Json::Value buildSnapshotTemplateConfig() {
  12. Json::Value templateConfig;
  13. Json::Value snapshotConfig;
  14. snapshotConfig["Count"] = "50";
  15. snapshotConfig["Interval"] = "1";
  16. snapshotConfig["SpecifiedOffsetTime"] = "0";
  17. snapshotConfig["Width"] = "200";
  18. snapshotConfig["Height"] = "200";
  19. snapshotConfig["FrameType"] = "normal";
  20. //雪碧图配置(雪碧图配置必须是建立在普通截图配置之上)
  21. Json::Value spriteSnapshotConfig;
  22. spriteSnapshotConfig["CellWidth"] = "120";
  23. spriteSnapshotConfig["CellHeight"] = "68";
  24. spriteSnapshotConfig["Columns"] = "3";
  25. spriteSnapshotConfig["Lines"] = "10";
  26. spriteSnapshotConfig["Padding"] = "20";
  27. spriteSnapshotConfig["Margin"] = "50";
  28. spriteSnapshotConfig["KeepCellPic"] = "keep";
  29. spriteSnapshotConfig["Color"] = "tomato";
  30. snapshotConfig["SpriteSnapshotConfig"] = spriteSnapshotConfig;
  31. //普通截图配置(与雪碧图原始图配置共用该配置信息)
  32. templateConfig["SnapshotConfig"] = snapshotConfig;
  33. //截图类型(存在雪碧图配置,该类型必须是"SpriteSnapshot",否则为"NormalSnapshot")
  34. templateConfig["SnapshotType"] = "SpriteSnapshot";
  35. return templateConfig;
  36. }
  37. /**
  38. * 添加截图模板函数
  39. */
  40. VodApiResponse addSnapshotVodTemplate(VodCredential authInfo) {
  41. string apiName = "AddVodTemplate";
  42. map<string, string> args;
  43. //模板名称
  44. args["Name"] = "Addtest";
  45. //模板类型,固定值为Snapshot
  46. args["TemplateType"] = "Snapshot";
  47. //截图模板配置数据生成
  48. Json::Value templateConfig = buildSnapshotTemplateConfig();
  49. args["TemplateConfig"] = templateConfig.toStyledString();
  50. return getAcsResponse(authInfo, apiName, args);
  51. }
  52. // 请求示例
  53. void main() {
  54. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  55. VodApiResponse response = addSnapshotVodTemplate(authInfo);
  56. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  57. }

修改截图模板

接口参数和返回字段请参考 UpdateVodTemplate

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 构建截图模板的配置数据,根据具体设置需求修改对应的参数值
  8. * (以下代码示例为雪碧图完整配置)
  9. * @return
  10. */
  11. Json::Value buildSnapshotTemplateConfig() {
  12. Json::Value templateConfig;
  13. Json::Value snapshotConfig;
  14. snapshotConfig["Count"] = "50";
  15. snapshotConfig["Interval"] = "1";
  16. snapshotConfig["SpecifiedOffsetTime"] = "0";
  17. snapshotConfig["Width"] = "200";
  18. snapshotConfig["Height"] = "200";
  19. snapshotConfig["FrameType"] = "normal";
  20. //雪碧图配置(雪碧图配置必须是建立在普通截图配置之上)
  21. Json::Value spriteSnapshotConfig;
  22. spriteSnapshotConfig["CellWidth"] = "120";
  23. spriteSnapshotConfig["CellHeight"] = "68";
  24. spriteSnapshotConfig["Columns"] = "3";
  25. spriteSnapshotConfig["Lines"] = "10";
  26. spriteSnapshotConfig["Padding"] = "20";
  27. spriteSnapshotConfig["Margin"] = "50";
  28. spriteSnapshotConfig["KeepCellPic"] = "keep";
  29. spriteSnapshotConfig["Color"] = "tomato";
  30. snapshotConfig["SpriteSnapshotConfig"] = spriteSnapshotConfig;
  31. //普通截图配置(与雪碧图原始图配置共用该配置信息)
  32. templateConfig["SnapshotConfig"] = snapshotConfig;
  33. //截图类型(存在雪碧图配置,该类型必须是"SpriteSnapshot",否则为"NormalSnapshot")
  34. templateConfig["SnapshotType"] = "SpriteSnapshot";
  35. return templateConfig;
  36. }
  37. /**
  38. * 修改截图模板函数
  39. */
  40. VodApiResponse updateSnapshotVodTemplate(VodCredential authInfo) {
  41. string apiName = "UpdateVodTemplate";
  42. map<string, string> args;
  43. //设置要修改的模板ID
  44. args["VodTemplateId"] = "53azf9d796fad9d7b862b2e5e5b";
  45. //模板名称
  46. args["Name"] = "updatetest";
  47. //截图模板配置数据生成
  48. Json::Value templateConfig = buildSnapshotTemplateConfig();
  49. args["TemplateConfig"] = templateConfig.toStyledString();
  50. return getAcsResponse(authInfo, apiName, args);
  51. }
  52. // 请求示例
  53. void main() {
  54. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  55. VodApiResponse response = updateSnapshotVodTemplate(authInfo);
  56. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  57. }

删除截图模板

接口参数和返回字段请参考 DeleteVodTemplate

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 删除截图模板函数
  8. */
  9. VodApiResponse deleteSnapshotVodTemplate(VodCredential authInfo) {
  10. string apiName = "DeleteVodTemplate";
  11. map<string, string> args;
  12. //设置要删除的模板ID
  13. args["VodTemplateId"] = "53azf9d796fad9d7b862b2e5e5b";
  14. return getAcsResponse(authInfo, apiName, args);
  15. }
  16. // 请求示例
  17. void main() {
  18. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. VodApiResponse response = deleteSnapshotVodTemplate(authInfo);
  20. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  21. }

查询截图模板列表

接口参数和返回字段请参考 ListVodTemplate

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 查询截图模板列表函数
  8. */
  9. VodApiResponse listSnapshotVodTemplate(VodCredential authInfo) {
  10. string apiName = "ListVodTemplate";
  11. map<string, string> args;
  12. //模板类型,固定值为Snapshot
  13. args["TemplateType"] = "Snapshot";
  14. return getAcsResponse(authInfo, apiName, args);
  15. }
  16. // 请求示例
  17. void main() {
  18. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. VodApiResponse response = listSnapshotVodTemplate(authInfo);
  20. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  21. }

查询截图模板

接口参数和返回字段请参考 GetVodTemplate

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 查询截图模板函数
  8. */
  9. VodApiResponse getSnapshotVodTemplate(VodCredential authInfo) {
  10. string apiName = "GetVodTemplate";
  11. map<string, string> args;
  12. //设置要查询的模板ID
  13. args["VodTemplateId"] = "53azf9d796fad9d7b862b2e5e5b";
  14. return getAcsResponse(authInfo, apiName, args);
  15. }
  16. // 请求示例
  17. void main() {
  18. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. VodApiResponse response = getSnapshotVodTemplate(authInfo);
  20. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  21. }