全部产品
存储与CDN 数据库 域名与网站(万网) 应用服务 数加·人工智能 数加·大数据基础服务 互联网中间件 视频服务 开发者工具 解决方案 物联网 钉钉智能硬件
视频直播

开发指南

更新时间:2018-01-29 17:20:04

开发者可利用导播服务API,构建定制化的控制台或者前端页面。

阅读对象

  • 具备java或者PHP开发能力

  • 了解导播产品的基本功能

  • 了解视频直播的基本功能

特别说明

  • 请开发者区分导播服务云导播台,导播服务仅提供API服务,需要开发者自行开发完成前端页面与交互部分,该文档适用于导播服务。

  • 云导播台用户请忽略该文档,视频直播控制提供云导播台产品,可直接使用前端页面进行导播操作。

准备

  • 开通视频点播服务,并绑定域名

  • 开通视频直播服务,并绑定域名

  • 初始导播台实例(通过控制台方式,按照流程指引设置、付费后自动创建导播台实例)

  • 获取视频直播SDK 并使用

导播操作

步骤 1: 配置导播台

  • 步骤说明

导播台创建完毕后,根据使用需求完成导播台名称、域名、转码、录制、延播、备播素材等配置。

  • 前提条件

    • 需提供经过备案的域名

    • 需要开通阿里云直播和点播服务

  • 接口说明

    • 设置导播台配置信息(SetCasterConfig)

    • 将客户提供的域名domainName绑定至导播台实例

    • 配置导播台输出分辨率casterTemplate

    • 配置导播台直播转码参数liveTemplate

    • 配置导播台直播录制参数recordConfig

    • 延播秒数及备播素材ID

  • 程序示例

  1. AliyunClient.init("yourAccessId", yourAccessSecret”);
  2. SetCasterConfigRequest setCasterConfigRequest = new SetCasterConfigRequest();
  3. setCasterConfigRequest.setCasterId("XXXXXX");
  4. setCasterConfigRequest.setCasterName("XXXXXX");
  5. setCasterConfigRequest.setDomainName("XXXXXX");
  6. setCasterConfigRequest.setDelay(10F);
  7. setCasterConfigRequest.setUrgentMaterialId("XXXXXX");
  8. JSONObject transcodeConfig = new JSONObject();
  9. JSONArray liveTemplate = new JSONArray();
  10. liveTemplate.add(“lld"); // 直播转码模板,lld-流畅,lsd-标清,lhd-高清,lud-超清
  11. transcodeConfig.put("LiveTemplate", liveTemplate);
  12. transcodeConfig.put("CasterTemplate", lp_ld"); // 导播台分辨率,lp_ld-流畅,lp_sd-标清,lp_hd-高清,lp_ud-超清
  13. JSONObject recordConfig = new JSONObject();
  14. JSONArray videoFormat = new JSONArray();
  15. videoFormat.add(new JSONObject().fluentPut("Format", "flv").fluentPut("OssObjectPrefix", "record/{AppName}/{StreamName}/{StartTime}_{EndTime}").fluentPut("CycleDuration", 15*60));
  16. videoFormat.add(new JSONObject().fluentPut("Format", "m3u8").fluentPut("OssObjectPrefix", "record/{AppName}/{StreamName}/{StartTime}_{EndTime}").fluentPut("SliceOssObjectPrefix", "record/{AppName}/{StreamName}/{UnixTimestamp}").fluentPut("CycleDuration", 15*60));
  17. recordConfig.put("VideoFormat", videoFormat);
  18. recordConfig.put("OssBucket", "ossBucket");
  19. recordConfig.put("OssEndpoint", "ossEndpoint");
  20. setCasterConfigRequest.setRecordConfig(recordConfig.toJSONString());
  21. setCasterConfigRequest.setTranscodeConfig(transcodeConfig.toJSONString());
  22. setCasterConfigRequest.setCallbackUrl(“http://XXX“);
  23. SetCasterConfigResponse response = AliyunClient.getAliyunClient().getAcsResponse(setCasterConfigRequest);

步骤 2:编辑视频源

  • 步骤说明

导播台创建完毕后,可配置用于输出的视频源信息,目前支持直播流及点播素材两种类型。

  • 前提条件

完成导播台实例创建

  • 接口说明

    • 新增视频源(AddCasterVideo)

    • 修改视频源(ModifyCasterVideoResource)

    • 查询视频源列表(DescribeCasterVideoResources)

    • 删除视频源(DeleteCasterVideoResource)

    • 配置视频源地址,视频源类型为直播流时需提供直播流地址liveStreamUrl,视频源类型为点播素材时需提供点播素材ID materialId及循环播放次数repeatNum

    • 配置视频源名称及视频源位置locationId,作为布局画面的引用编号

  • 程序示例

  1. // 新增视频源(AddCasterVideo)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. AddCasterVideoResourceRequest addCasterVideoResourceRequest = new AddCasterVideoResourceRequest();
  4. addCasterVideoResourceRequest.setCasterId("XXXXXX");
  5. addCasterVideoResourceRequest.setResourceName("XXXXXX");
  6. addCasterVideoResourceRequest.setLocationId("RV01" ); // RV01-RV12视频源的RVXX代表位置ID,不可重复,布局通过该ID引用视频源
  7. addCasterVideoResourceRequest.setLiveStreamUrl( null); // 采用点播素材时不输入
  8. addCasterVideoResourceRequest.setMaterialId("XXXXXX");
  9. addCasterVideoResourceRequest.setRepeatNum( -1); // 视频播放完毕后循环播放
  10. AddCasterVideoResourceResponse response = AliyunClient.getAliyunClient().getAcsResponse(addCasterVideoResourceRequest);
  11. // 修改视频源(AddCasterVideo)
  12. AliyunClient.init("yourAccessId", yourAccessSecret”);
  13. ModifyCasterVideoResourceRequest modifyCasterVideoResourceRequest = new ModifyCasterVideoResourceRequest();
  14. modifyCasterVideoResourceRequest.setCasterId("XXXXXX");
  15. modifyCasterVideoResourceRequest.setResourceId("XXXXXX");
  16. modifyCasterVideoResourceRequest.setLiveStreamUrl(“rtmp://XXXX“);
  17. modifyCasterVideoResourceRequest.setResourceName("XXXXXX");
  18. ModifyCasterVideoResourceResponse response = AliyunClient.getAliyunClient().getAcsResponse(modifyCasterVideoResourceRequest);
  19. // 查询视频源列表(DescribeCasterVideo)
  20. AliyunClient.init("yourAccessId", yourAccessSecret”);
  21. DescribeCasterVideoResourcesRequest describeCasterVideoResourcesRequest = new DescribeCasterVideoResourcesRequest();
  22. describeCasterVideoResourcesRequest.setCasterId("XXXXXX");
  23. DescribeCasterVideoResourcesResponse response = AliyunClient.getAliyunClient().getAcsResponse(describeCasterVideoResourcesRequest);
  24. // 删除视频源列表(DescribeCasterVideo)
  25. AliyunClient.init("yourAccessId", yourAccessSecret”);
  26. DeleteCasterVideoResourceRequest deleteCasterVideoResourceRequest = new DeleteCasterVideoResourceRequest();
  27. deleteCasterVideoResourceRequest.setCasterId("XXXXXX");
  28. deleteCasterVideoResourceRequest.setResourceId("XXXXXX");
  29. DeleteCasterVideoResourceResponse response = AliyunClient.getAliyunClient().getAcsResponse(deleteCasterVideoResourceRequest);

步骤 3: 编辑组件

  • 步骤说明

导播台创建完毕后,可配置用于输出的组件信息,目前支持文字及图片两种类型

  • 前提条件

完成导播台实例创建

  • 接口说明

    • 新增组件(AddCasterComponent)

    • 修改组件(ModifyCasterComponent)

    • 查询组件列表(DescribeCasterComponents)

    • 删除组件(DeleteCasterComponent)

    • 配置组件内容,文字组件需提供文字内容、字体归一化比例、颜色等,图片组件需提供图片素材ID

  • 程序示例

  1. // 新增组件(AddCasterComponent)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. JSONObject componentLayer = new JSONObject();
  4. componentLayer.put("HeightNormalized", 0.2);
  5. componentLayer.put("WidthNormalized", 0.2);
  6. JSONArray positionNormalized = new JSONArray();
  7. positionNormalized.add("0.3");
  8. positionNormalized.add("0.3");
  9. componentLayer.put("PositionNormalized", positionNormalized);
  10. componentLayer.put("PositionRefer", "topLeft");
  11. // 组件TextLayerContent
  12. JSONObject textLayerContent = new JSONObject();
  13. textLayerContent.put("Text", text);
  14. textLayerContent.put("Color", 0xff0000);
  15. textLayerContent.put("FontName", "KaiTi");
  16. textLayerContent.put("SizeNormalized", 0.3F);
  17. textLayerContent.put("BorderWidthNormalized", 0.3F);
  18. textLayerContent.put("BorderColor", 0xff0000);
  19. // 设置组件元素属性
  20. AddCasterComponentRequest addCasterComponntRequest = new AddCasterComponentRequest();
  21. addCasterComponntRequest.setCasterId(casterId);
  22. addCasterComponntRequest.setLocationId(locationId);
  23. addCasterComponntRequest.setComponentName(componentName);
  24. addCasterComponntRequest.setComponentType("text");
  25. addCasterComponntRequest.setEffect(effect);
  26. addCasterComponntRequest.setComponentLayer(componentLayer.toJSONString());
  27. addCasterComponntRequest.setTextLayerContent(textLayerContent.toJSONString());
  28. AddCasterComponentResponse response = AliyunClient.getAliyunClient().getAcsResponse(addCasterComponntRequest);
  29. // 修改组件(ModifyCasterComponent)
  30. AliyunClient.init("yourAccessId", yourAccessSecret”);
  31. JSONObject componentLayer = new JSONObject();
  32. componentLayer.put("HeightNormalized", 0.6);
  33. componentLayer.put("WidthNormalized", 0.6);
  34. JSONArray positionNormalized = new JSONArray();
  35. positionNormalized.add("0.3");
  36. positionNormalized.add("0.3");
  37. componentLayer.put("PositionNormalized", positionNormalized);
  38. componentLayer.put("PositionRefer", "topLeft");
  39. // 组件TextLayerContent
  40. JSONObject textLayerContent = new JSONObject();
  41. textLayerContent.put("Text", text);
  42. textLayerContent.put("Color", 0xff0000);
  43. textLayerContent.put("FontName", "KaiTi");
  44. textLayerContent.put("SizeNormalized", 0.3F);
  45. textLayerContent.put("BorderWidthNormalized", 0.3F);
  46. textLayerContent.put("BorderColor", 0xff0000);
  47. // 设置组件元素属性
  48. ModifyCasterComponentRequest modifyCasterComponentRequest = new ModifyCasterComponentRequest();
  49. modifyCasterComponentRequest.setCasterId("XXXXXX");
  50. modifyCasterComponentRequest.setComponentId("XXXXXX");
  51. modifyCasterComponentRequest.setComponentName("XXXXXX");
  52. modifyCasterComponentRequest.setComponentType(“text"); // 文本类型
  53. modifyCasterComponentRequest.setEffect(“none"); // 无特效
  54. modifyCasterComponentRequest.setComponentLayer(componentLayer.toJSONString());
  55. modifyCasterComponentRequest.setTextLayerContent(textLayerContent.toJSONString());
  56. ModifyCasterComponentResponse response = AliyunClient.getAliyunClient().getAcsResponse(modifyCasterComponentRequest);
  57. // 查询组件列表(DescribeCasterComponents)
  58. AliyunClient.init("yourAccessId", yourAccessSecret”);
  59. DescribeCasterComponentsRequest describeCasterComponentsRequest= new DescribeCasterComponentsRequest();
  60. describeCasterComponentsRequest.setCasterId("XXXXXX");
  61. DescribeCasterComponentsResponse response = AliyunClient.getAliyunClient().getAcsResponse(describeCasterComponentsRequest);
  62. // 删除组件列表(DescribeCasterComponent)
  63. AliyunClient.init("yourAccessId", yourAccessSecret”);
  64. DeleteCasterComponentRequest deleteCasterComponentRequest = new DeleteCasterComponentRequest();
  65. deleteCasterComponentRequest.setCasterId("XXXXXX");
  66. deleteCasterComponentRequest.setComponentId("XXXXXX");
  67. DeleteCasterComponentResponse response = AliyunClient.getAliyunClient().getAcsResponse(deleteCasterComponentRequest);

步骤 4: 编辑布局

  • 步骤说明

导播台创建完毕后,可配置用于导播输出的画面布局,用户可自定义画面及位置,目前支持最多四个画面。

  • 前提条件

完成导播台实例创建

  • 接口说明

    • 新增布局(AddCasterLayout)

    • 修改布局(ModifyCasterLayout)

    • 查询布局列表(DescribeCasterLayouts)

    • 删除视频源(DeleteCasterLayout)

    • 配置布局样式信息列表videoLayer、音频配置信息列表audioLayer

    • 配置视频源位置列表blendList、音频位置列表mixList

  • 程序示例

  1. // 新增布局(AddCasterLayout)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. JSONObject componentLayer = new JSONObject();
  4. componentLayer.put("HeightNormalized", 0.6);
  5. componentLayer.put("WidthNormalized", 0.6);
  6. JSONArray positionNormalized = new JSONArray();
  7. positionNormalized.add("0.3");
  8. positionNormalized.add("0.3");
  9. componentLayer.put("PositionNormalized", positionNormalized);
  10. componentLayer.put("PositionRefer", "topLeft");
  11. // 组件ImageLayerContent
  12. JSONObject imageLayerContent = new JSONObject();
  13. imageLayerContent.put("MaterialId", "materailId");
  14. // 设置组件元素属性
  15. AddCasterComponentRequest addCasterComponntRequest = new AddCasterComponentRequest();
  16. addCasterComponntRequest.setCasterId("XXXXXX");
  17. addCasterComponntRequest.setLocationId(“RC01"); // 与组件关联的LocationId
  18. addCasterComponntRequest.setComponentName("XXXXXX");
  19. addCasterComponntRequest.setComponentType(“image"); // 图片类型
  20. addCasterComponntRequest.setEffect(“none"); // 无特效
  21. addCasterComponntRequest.setComponentLayer(componentLayer.toJSONString());
  22. addCasterComponntRequest.setImageLayerContent(imageLayerContent.toJSONString());
  23. AddCasterComponentResponse response = AliyunClient.getAliyunClient().getAcsResponse(addCasterComponntRequest);
  24. // 修改布局(ModifyCasterLayout)
  25. AliyunClient.init("yourAccessId", yourAccessSecret”);
  26. ModifyCasterLayoutRequest modifyCasterLayoutRequest = new ModifyCasterLayoutRequest();
  27. modifyCasterLayoutRequest.setCasterId("XXXXXX");
  28. modifyCasterLayoutRequest.setLayoutId("XXXXXX");
  29. // 视频layer
  30. List<ModifyCasterLayoutRequest.VideoLayer> videoLayersList = new ArrayList<ModifyCasterLayoutRequest.VideoLayer>();
  31. ModifyCasterLayoutRequest.VideoLayer videoLayer1 = new ModifyCasterLayoutRequest.VideoLayer();
  32. videoLayer1.setHeightNormalized(0.5F);
  33. videoLayer1.setWidthNormalized(0.5F);
  34. videoLayer1.setPositionRefer("topLeft");
  35. videoLayer1.setPositionNormalizeds(Arrays.asList(new Float[]{0F, 0F}));
  36. videoLayersList.add(videoLayer1);
  37. ModifyCasterLayoutRequest.VideoLayer videoLayer2 = new ModifyCasterLayoutRequest.VideoLayer();
  38. videoLayer2.setHeightNormalized(0.5F);
  39. videoLayer2.setWidthNormalized(0.5F);
  40. videoLayer2.setPositionRefer("topLeft");
  41. videoLayer2.setPositionNormalizeds(Arrays.asList(new Float[]{0.5F, 0F}));
  42. videoLayersList.add(videoLayer2);
  43. ModifyCasterLayoutRequest.VideoLayer videoLayer3 = new ModifyCasterLayoutRequest.VideoLayer();
  44. videoLayer3.setHeightNormalized(0.5F);
  45. videoLayer3.setWidthNormalized(0.5F);
  46. videoLayer3.setPositionRefer("topLeft");
  47. videoLayer3.setPositionNormalizeds(Arrays.asList(new Float[]{0.2F, 0.5F}));
  48. videoLayersList.add(videoLayer3);
  49. modifyCasterLayoutRequest.setVideoLayers(videoLayersList);
  50. List<ModifyCasterLayoutRequest.AudioLayer> audioLayerList = new ArrayList<ModifyCasterLayoutRequest.AudioLayer>();
  51. // 音频layer
  52. ModifyCasterLayoutRequest.AudioLayer audioLayer1 = new ModifyCasterLayoutRequest.AudioLayer();
  53. audioLayer1.setVolumeRate(1F);
  54. audioLayer1.setValidChannel("all");
  55. audioLayerList.add(audioLayer1);
  56. ModifyCasterLayoutRequest.AudioLayer audioLayer2 = new ModifyCasterLayoutRequest.AudioLayer();
  57. audioLayer2.setVolumeRate(1F);
  58. audioLayer2.setValidChannel("all");
  59. audioLayerList.add(audioLayer2);
  60. ModifyCasterLayoutRequest.AudioLayer audioLayer3 = new ModifyCasterLayoutRequest.AudioLayer();
  61. audioLayer3.setVolumeRate(1F);
  62. audioLayer3.setValidChannel("all");
  63. audioLayerList.add(audioLayer3);
  64. modifyCasterLayoutRequest.setAudioLayers(audioLayerList);
  65. modifyCasterLayoutRequest.setBlendLists(Arrays.asList(new String[]{“RV01", "RV02", RV03”}));
  66. modifyCasterLayoutRequest.setMixLists(Arrays.asList(new String[]{"RV01", "RV02", "RV03"}));
  67. ModifyCasterLayoutResponse response = AliyunClient.getAliyunClient().getAcsResponse(modifyCasterLayoutRequest);
  68. // 查询布局列表(DescribeCasterLayout)
  69. AliyunClient.init("yourAccessId", yourAccessSecret”);
  70. DescribeCasterLayoutsRequest request = new DescribeCasterLayoutsRequest();
  71. request.setCasterId("XXXXXX");
  72. DescribeCasterLayoutsResponse response = AliyunClient.getAliyunClient().getAcsResponse(request);
  73. // 删除布局(DescribeCasterLayout)
  74. AliyunClient.init("yourAccessId", yourAccessSecret”);
  75. DeleteCasterLayoutRequest deleteCasterLayoutRequest = new DeleteCasterLayoutRequest();
  76. deleteCasterLayoutRequest.setCasterId("XXXXXX");
  77. deleteCasterLayoutRequest.setLayoutId("XXXXXX");
  78. DeleteCasterLayoutResponse response = AliyunClient.getAliyunClient().getAcsResponse(deleteCasterLayoutRequest);

步骤 5: 启动导播台

  • 步骤说明

导播台创建并配置完毕后,即可启动导播台,启动底层音视频处理任务。

  • 前提条件

    • 完成导播台实例创建

    • 完成导播台配置,包括域名、导播台输出分辨率等

  • 接口说明

    • 启动导播台(StartCaster)

    • 指定需要启动的导播台实例ID CasterID

    • 接口启动成功后返回PVW及PGM场景信息列表,包括场景ID及流信息等,后续操作指定场景时指定场景ID即可。

  • 程序示例

  1. // 启动导播台(StartCaster)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. StartCasterSceneRequest startCasterSceneRequest = new StartCasterSceneRequest();
  4. startCasterSceneRequest.setCasterId("XXXXXX");
  5. startCasterSceneRequest.setSceneId("XXXXXX");
  6. StartCasterSceneResponse response = AliyunClient.getAliyunClient().getAcsResponse(startCasterSceneRequest);

步骤 6:更新场景

  • 步骤说明

导播台启动成功后,可将已配置好的布局(组件)生效至指定场景。

  • 前提条件

    • 完成导播台实例创建

    • 完成指定布局(组件)的编辑

    • 指定场景存在并启动

  • 接口说明

    • 更新场景配置(UpdateCasterSceneConfig)

    • 删除场景配置(DeleteCasterSceneConfig)

    • 指定导播台实例ID CasterID

    • 指定场景ID SceneID

    • 指定布局ID LayoutID,若未指定则默认无变更。

  • 程序示例

  1. // 更新场景配置(UpdateCasterSceneConfig)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. UpdateCasterSceneConfigRequest updateCasterSceneConfigRequest = new UpdateCasterSceneConfigRequest();
  4. updateCasterSceneConfigRequest.setCasterId("XXXXXX");
  5. updateCasterSceneConfigRequest.setLayoutId("XXXXXX");
  6. updateCasterSceneConfigRequest.setSceneId("XXXXXX");
  7. updateCasterSceneConfigRequest.setComponentIds(componentList);
  8. UpdateCasterSceneConfigResponse response = AliyunClient.getAliyunClient().getAcsResponse(updateCasterSceneConfigRequest);
  9. . 删除场景配置(DeleteCasterSceneConfig
  10. AliyunClient.init("yourAccessId", yourAccessSecret”);
  11. DeleteCasterSceneConfigRequest deleteCasterSceneConfigRequest = new DeleteCasterSceneConfigRequest();
  12. deleteCasterSceneConfigRequest.setCasterId("XXXXXX");
  13. deleteCasterSceneConfigRequest.setLayoutId("XXXXXX");
  14. deleteCasterSceneConfigRequest.setType(“Component") // 清除场景中的组件配置
  15. DeleteCasterSceneConfigResponse response = AliyunClient.getAliyunClient().getAcsResponse(deleteCasterSceneConfigRequest);

步骤 7:PVW切换到PGM

  • 步骤说明

导播台启动成功后,可将PVW的布局配置信息设置到PGM场景。

  • 前提条件

    • 完成导播台实例创建

    • PVW场景存在并启动

    • PGM场景存在并启动

  • 接口说明

    • 更新场景配置(CopyCasterSceneConfig)

    • 指定导播台实例ID CasterID

    • 指定PVW场景ID FromSceneID

    • 指定PGM场景ID ToSceneID

  • 程序示例

  1. // 场景切换(CopyCasterSceneConfig)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. CopyCasterSceneConfigRequest copyCasterSceneConfigRequest = new CopyCasterSceneConfigRequest();
  4. copyCasterSceneConfigRequest.setCasterId("XXXXXX");
  5. copyCasterSceneConfigRequest.setFromSceneId("XXXXXX");
  6. copyCasterSceneConfigRequest.setToSceneId("XXXXXX");
  7. CopyCasterSceneConfigResponse response = AliyunClient.getAliyunClient().getAcsResponse(copyCasterSceneConfigRequest);

步骤 8:预监开启、关闭

  • 步骤说明

导播台启动成功后,可通过预监开启、关闭服务控制PVW场景,关闭PVW场景后布局及视频源变动可直接生效至PGM场景。

  • 前提条件

    • 完成导播台实例创建

    • PVW场景存在

  • 接口说明

    • 预监开启(StartCasterScene)

    • 预监关闭(StopCasterScene)

    • 指定导播台实例ID CasterID

    • 指定PVW场景ID SceneID

  • 程序示例

  1. // 预监开启(StartCasterScene)
  2. AliyunClient.init("yourAccessId", yourAccessSecret”);
  3. StartCasterSceneRequest startCasterSceneRequest = new StartCasterSceneRequest();
  4. startCasterSceneRequest.setCasterId("XXXXXX");
  5. startCasterSceneRequest.setSceneId("XXXXXX");
  6. StartCasterSceneResponse response = AliyunClient.getAliyunClient().getAcsResponse(startCasterSceneRequest);
  7. // 预监关闭(StopCasterScene)
  8. AliyunClient.init("yourAccessId", yourAccessSecret”);
  9. StopCasterSceneRequest stopCasterSceneRequest = new StopCasterSceneRequest();
  10. stopCasterSceneRequest.setCasterId("XXXXXX");
  11. stopCasterSceneRequest.setSceneId("XXXXXX");
  12. StopCasterSceneResponse response = AliyunClient.getAliyunClient().getAcsResponse(stopCasterSceneRequest);

步骤 9: 备播切换、切回

  • 步骤说明

导播台启动成功后,可通过备播切换服务将PGM场景切换至备播画面,若需要切回直播场景可通过回切直播服务完成。

  • 前提条件

    • 导播台实例已启动

    • 完成备播素材ID配置

  • 接口说明

    • 备播紧急生效(EffectCasterUrgent)

    • 切回直播(SetCasterSceneConfig)

    • 指定导播台实例ID (CasterID)

    • 指定PGM场景实例ID (SceneID)

  • 程序示例

  1. // 切换备播(StartCasterScene)
  2. AliyunClient.init("yourAccessId", yourAccessSecret");
  3. EffectCasterUrgentRequest effectCasterUrgentRequest = new EffectCasterUrgentRequest();
  4. effectCasterUrgentRequest.setCasterId("XXXXXX");
  5. effectCasterUrgentRequest.setSceneId("XXXXXX");
  6. EffectCasterUrgentResponse response = AliyunClient.getAliyunClient().getAcsResponse(effectCasterUrgentRequest);
  7. // 切回直播(StopCasterScene)
  8. AliyunClient.init("yourAccessId", yourAccessSecret");
  9. SetCasterSceneConfigRequest setCasterSceneConfigRequest = new SetCasterSceneConfigRequest();
  10. setCasterSceneConfigRequest.setCasterId("XXXXXX");
  11. setCasterSceneConfigRequest.setSceneId("XXXXXX");
  12. setCasterSceneConfigRequest.setLayoutId(null); // 若需要退出备播播放传null,若需要转到指定布局输入layoutId即可
  13. SetCasterSceneConfigResponse response = AliyunClient.getAliyunClient().getAcsResponse(setCasterSceneConfigRequest);

步骤 10: 停止导播台

  • 步骤说明

导播台启动成功后,可通过停止导播台服务停止指定导播台及底层音视频任务。

  • 前提条件

导播台实例已启动

  • 接口说明

    • 停止导播台(StopCaster)

    • 指定导播台实例ID CasterID

  • 程序示例

  1. // 停止导播台(StopCaster)
  2. AliyunClient.init("yourAccessId", "yourAccessSecret");
  3. StopCasterRequest request = new StopCasterRequest();
  4. request.setCasterId("XXXXXX");
  5. StopCasterResponse response = AliyunClient.getAliyunClient().getAcsResponse(request);
本文导读目录