This topic describes how to use the API operations that are related to the production studio feature.
Notes
This topic discusses the production studio feature based on only API operations, which is different from actual production studios. To use the production studio feature based on API operations, you must develop a frontend web page that allows interaction.
The ApsaraVideo Live console provides production studios and a frontend web page for you to orchestrate videos. If you use production studios in the console, you can skip this topic. For more information, see Get started with a production studio.
Intended readers
Java or PHP developers. For more information, see Use the server SDK for Java.
Understanding the basic features of Director
Developers who understand the basic features of ApsaraVideo Live.
Prerequisites
The production studio feature is enabled, and a domain name is added. For more information, see Enable the production studio feature.
You can download ApsaraVideo Live SDK.
Procedure
Configure a production studio.
Description
After you create a production studio, you can configure the settings of the production studio as needed, such as the production studio name, domain name, transcoding, recording, stream delay, and standby resource.
Related API operations
SetCasterConfig - Configure a production studio
Sample code
/** * Configure a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @throws Exception Throws an exception if an error occurs during the configuration. */ private void setCasterConfig(Client client, String casterId) throws Exception { SetCasterConfigRequest request = new SetCasterConfigRequest(); request.setCasterId(casterId); // Configure the domain name. request.setDomainName("domainName"); // Transcoding configuration. JSONObject transcodeConfig = new JSONObject(); // Live stream transcoding configuration. lsd: standard definition. lld: low definition. lud: ultra-high definition. lhd: high definition with automatic rotation. daobo-lsd: standard definition. daobo-lld: low definition. daobo-lud: ultra-high definition. daobo-lhd: high definition. JSONObject liveTemplateIds = new JSONObject(); JSONArray locationId = new JSONArray(); locationId.add("lld"); liveTemplateIds.put("LocationId", locationId); transcodeConfig.put("LiveTemplateIds", liveTemplateIds); // Production studio transcoding template. lp_ld: low definition. lp_sd: standard definition. lp_hd: high definition. lp_ud: ultra-high definition. lp_ld_v: vertical low definition. lp_sd_v: vertical standard definition. lp_hd_v: vertical high definition. lp_ud_v: vertical ultra-high definition. transcodeConfig.put("CasterTemplate", "lp_sd"); request.setTranscodeConfig(transcodeConfig.toJSONString()); // Configure the live stream recording parameters for the production studio. JSONObject recordConfig = new JSONObject(); recordConfig.put("endpoint", ""); recordConfig.put("ossBucket", ""); recordConfig.put("videoFormat", ""); recordConfig.put("interval", 5); request.setRecordConfig(recordConfig.toJSONString()); SetCasterConfigResponse response = client.setCasterConfig(request); System.out.println("Add production studio configuration. response: " + JSON.toJSONString(response)); }Edit video sources.
Description
Configure video sources that are used to produce the output content. You can use live streams and on-demand videos as video sources.
Related API operations
AddCasterVideoResource - Add a video resource to a production studio
DescribeCasterVideoResources - Query the video sources of a production studio
ModifyCasterVideoResource - Modify a video source of a production studio
DeleteCasterVideoResource - Delete a video resource from a production studio
Sample code
/** * Add a video source to the specified production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio to which you want to add the video source. * @return The ID of the added video resource. * @throws Exception Throws an exception if the API call fails or other exceptions occur. */ private String addCasterVideoResource(Client client, String casterId) throws Exception { AddCasterVideoResourceRequest addCasterVideoResourceRequest = new AddCasterVideoResourceRequest(); addCasterVideoResourceRequest.setCasterId(casterId); addCasterVideoResourceRequest.setResourceName("testResourceName"); addCasterVideoResourceRequest.setMaterialId(""); // Set the number of replays. The value can be from -1 to 60. The default value is 0, which indicates no replay. -1 indicates an infinite loop. addCasterVideoResourceRequest.setRepeatNum(-1); AddCasterVideoResourceResponse addCasterVideoResourceResponse = client.addCasterVideoResource(addCasterVideoResourceRequest); System.out.println("Add video source. response: " + JSON.toJSONString(addCasterVideoResourceResponse)); return addCasterVideoResourceResponse.getBody().getResourceId(); } /** * Query the list of video source resources for a specified production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio that you want to query. * @return DescribeCasterVideoResourcesResponse The response object that contains the list of video source resources. * @throws Exception An exception that may be thrown during the API call. */ private DescribeCasterVideoResourcesResponse describeCasterVideoResources(Client client, String casterId) throws Exception { DescribeCasterVideoResourcesRequest describeCasterVideoResourcesRequest = new DescribeCasterVideoResourcesRequest(); describeCasterVideoResourcesRequest.setCasterId(casterId); DescribeCasterVideoResourcesResponse describeCasterVideoResourcesResponse = client.describeCasterVideoResources(describeCasterVideoResourcesRequest); System.out.println("Query video source list. response: " + JSON.toJSONString(describeCasterVideoResourcesResponse)); return describeCasterVideoResourcesResponse; } /** * Modify a video resource of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param resourceId The ID of the resource. * @throws Exception Throws an exception if the API call fails. */ private void modifyCasterVideoResource(Client client, String casterId, String resourceId) throws Exception { ModifyCasterVideoResourceRequest modifyCasterVideoResourceRequest = new ModifyCasterVideoResourceRequest(); modifyCasterVideoResourceRequest.setCasterId(casterId); modifyCasterVideoResourceRequest.setResourceId(resourceId); modifyCasterVideoResourceRequest.setResourceName("newResourceName"); modifyCasterVideoResourceRequest.setMaterialId(""); modifyCasterVideoResourceRequest.setVodUrl(""); modifyCasterVideoResourceRequest.setRepeatNum(-1); ModifyCasterVideoResourceResponse modifyCasterVideoResourceResponse = client.modifyCasterVideoResource(modifyCasterVideoResourceRequest); System.out.println("Modify video source. response: " + JSON.toJSONString(modifyCasterVideoResourceResponse)); } /** * Delete a video source. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param resourceId The ID of the resource. * @throws Exception Throws an exception if the API call fails. */ private void deleteCasterVideoResource(Client client, String casterId, String resourceId) throws Exception { DeleteCasterVideoResourceRequest deleteCasterVideoResourceRequest = new DeleteCasterVideoResourceRequest(); deleteCasterVideoResourceRequest.setCasterId(casterId); deleteCasterVideoResourceRequest.setResourceId(resourceId); DeleteCasterVideoResourceResponse deleteCasterVideoResourceResponse = client.deleteCasterVideoResource(deleteCasterVideoResourceRequest); System.out.println("Delete video source. response: " + JSON.toJSONString(deleteCasterVideoResourceResponse)); }Edit components.
Description
Configure components that are used to produce the output content. Supported components include text and images.
Related API operations
DescribeCasterComponents - Query the components of a production studio
ModifyCasterComponent - Modify a component of a production studio
DeleteCasterComponent - Delete a component from a production studio
NoteYou must configure the following information about components:
If the component is text, set the properties such as text content, font proportion, and colors.
If the component is an image, specify the ID of the image component.
Sample code
/** * Add a text component to the specified production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @return The unique identifier (ComponentId) of the newly added component. * @throws Exception Throws an exception if an error occurs during the request. */ private String addCasterComponent(Client client, String casterId) throws Exception { // Construct the componentLayer parameter: Set the size and position of the component on the screen. JSONObject componentLayer = new JSONObject(); componentLayer.put("HeightNormalized", 0.2); componentLayer.put("WidthNormalized", 0.2); JSONArray positionNormalized = new JSONArray(); positionNormalized.add("0.3"); positionNormalized.add("0.3"); componentLayer.put("PositionNormalized", positionNormalized); componentLayer.put("PositionRefer", "topLeft"); // Construct the text layer content: Set properties such as text, color, and font. JSONObject textLayerContent = new JSONObject(); // The TextLayerContent component. textLayerContent.put("Text", "hello world!"); textLayerContent.put("Color", 0xff0000); textLayerContent.put("FontName", "KaiTi"); textLayerContent.put("SizeNormalized", 0.3F); textLayerContent.put("BorderWidthNormalized", 0.3F); textLayerContent.put("BorderColor", 0xff0000); // Construct the request object for adding a component and set the relevant parameters. AddCasterComponentRequest addCasterComponentRequest = new AddCasterComponentRequest(); // Set the properties of the component element. addCasterComponentRequest.setCasterId(casterId); // Used to specify the component position. You can set a maximum of one component for each position. The format must be "RC01 to RC99". addCasterComponentRequest.setLocationId("RC01"); // The name of the component. addCasterComponentRequest.setComponentName("testComponentName"); // The type of the component. Valid values: text: a text component. You must also set the TextLayerContent parameter. image: an image component. You must also set the ImageLayerContent parameter. caption: a caption component. You must also set the CaptionLayerContent parameter. addCasterComponentRequest.setComponentType("text"); addCasterComponentRequest.setTextLayerContent(textLayerContent.toJSONString()); // The effect of the component. Valid values: none: (default) no effect. animateH: horizontal scroll. animateV: vertical scroll. addCasterComponentRequest.setEffect("animateH"); // The size of the component layer. addCasterComponentRequest.setComponentLayer(componentLayer.toJSONString()); // Send the request and obtain the response. AddCasterComponentResponse addCasterComponentResponse = client.addCasterComponent(addCasterComponentRequest); System.out.println("Add component, return value: " + JSON.toJSONString(addCasterComponentResponse)); // Return the ID of the new component. return addCasterComponentResponse.getBody().getComponentId(); } /** * Query the component list of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio that you want to query. * @param componentId The ID of the component that you want to query. * @return DescribeCasterComponentsResponse The response object for the component list. * @throws Exception Throws an exception if an error occurs during the API request or processing. */ private DescribeCasterComponentsResponse describeCasterComponents(Client client, String casterId, String componentId) throws Exception { // Construct the request object for querying the component list of the production studio. DescribeCasterComponentsRequest describeCasterComponentsRequest = new DescribeCasterComponentsRequest(); describeCasterComponentsRequest.setCasterId(casterId); describeCasterComponentsRequest.setComponentId(componentId); DescribeCasterComponentsResponse describeCasterComponentsResponse = client.describeCasterComponents(describeCasterComponentsRequest); System.out.println("Query component list, return value: " + JSON.toJSONString(describeCasterComponentsResponse)); return describeCasterComponentsResponse; } /** * Update a component of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param componentId The ID of the component. * @throws Exception Throws an exception if an error occurs during the API request or processing. */ private void modifyCasterComponent(Client client, String casterId, String componentId) throws Exception { JSONObject componentLayer = new JSONObject(); componentLayer.put("HeightNormalized", 0.6); componentLayer.put("WidthNormalized", 0.6); JSONArray positionNormalized = new JSONArray(); positionNormalized.add("0.3"); positionNormalized.add("0.3"); componentLayer.put("PositionNormalized", positionNormalized); componentLayer.put("PositionRefer", "topLeft"); JSONObject textLayerContent = new JSONObject();// The TextLayerContent component. textLayerContent.put("Text", "hello world!"); textLayerContent.put("Color", 0xff0000); textLayerContent.put("FontName", "KaiTi"); textLayerContent.put("SizeNormalized", 0.3F); textLayerContent.put("BorderWidthNormalized", 0.3F); textLayerContent.put("BorderColor", 0xff0000); ModifyCasterComponentRequest modifyCasterComponentRequest = new ModifyCasterComponentRequest(); // Set the properties of the component element. modifyCasterComponentRequest.setCasterId(casterId); modifyCasterComponentRequest.setComponentId(componentId); modifyCasterComponentRequest.setComponentName("newComponentName"); modifyCasterComponentRequest.setComponentType("text"); modifyCasterComponentRequest.setTextLayerContent(textLayerContent.toJSONString()); modifyCasterComponentRequest.setEffect("none"); // No effect. modifyCasterComponentRequest.setComponentLayer(componentLayer.toJSONString()); ModifyCasterComponentResponse modifyCasterComponentResponse = client.modifyCasterComponent(modifyCasterComponentRequest); System.out.println("Modify component, return value: " + JSON.toJSONString(modifyCasterComponentResponse)); } /** * Delete a caster component. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param componentId The ID of the component. * @throws Exception An exception that may be thrown during the delete operation. */ private void deleteCasterComponent(Client client, String casterId, String componentId) throws Exception { // Construct the request object for deleting a component and set the parameters. DeleteCasterComponentRequest deleteCasterComponentRequest = new DeleteCasterComponentRequest(); deleteCasterComponentRequest.setCasterId(casterId); deleteCasterComponentRequest.setComponentId(componentId); // Call the client interface to perform the delete operation. DeleteCasterComponentResponse deleteCasterComponentResponse = client.deleteCasterComponent(deleteCasterComponentRequest); // Output the deletion result. System.out.println("Delete component, return value: " + JSON.toJSONString(deleteCasterComponentResponse)); }Edit layouts.
Description
Configure the layouts of the output content. You can customize screens and their locations. Up to four screens can be created in a layout.
Related API operations
DescribeCasterLayouts - Query the layouts of a production studio
DeleteCasterLayout - Delete the layout data of a production studio
Sample code
/** * Add a layout to a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio to operate on. * @return The ID of the newly created layout. * @throws Exception Throws an exception if the API call fails or other exceptions occur. */ private String addCasterLayout(Client client, String casterId) throws Exception { // Create a request object for adding a production studio layout and set the basic parameters. AddCasterLayoutRequest addCasterLayoutRequest = new AddCasterLayoutRequest(); addCasterLayoutRequest.setCasterId(casterId); addCasterLayoutRequest.setBlendList(Arrays.asList("RV01")); addCasterLayoutRequest.setMixList(Arrays.asList("RV01")); // Configure the video layer parameters. List<AddCasterLayoutRequest.AddCasterLayoutRequestVideoLayer> videoLayers = new ArrayList<>(); AddCasterLayoutRequest.AddCasterLayoutRequestVideoLayer videoLayer = new AddCasterLayoutRequest.AddCasterLayoutRequestVideoLayer(); videoLayer.setFillMode("fit"); videoLayer.setHeightNormalized(0.5F); videoLayer.setWidthNormalized(0.5F); videoLayer.setPositionRefer("topLeft"); videoLayer.setPositionNormalized(Arrays.asList(0.1F, 0.1F)); videoLayer.setFixedDelayDuration(0); videoLayers.add(videoLayer); addCasterLayoutRequest.setVideoLayer(videoLayers); // Configure the audio layer parameters. List<AddCasterLayoutRequest.AddCasterLayoutRequestAudioLayer> audioLayers = new ArrayList<>(); AddCasterLayoutRequest.AddCasterLayoutRequestAudioLayer audioLayer = new AddCasterLayoutRequest.AddCasterLayoutRequestAudioLayer(); audioLayer.setVolumeRate(1.0F); audioLayer.setValidChannel("all"); audioLayer.setFixedDelayDuration(0); audioLayers.add(audioLayer); addCasterLayoutRequest.setAudioLayer(audioLayers); // Call the API to add a production studio layout. AddCasterLayoutResponse addCasterLayoutResponse = client.addCasterLayout(addCasterLayoutRequest); System.out.println("Add production studio layout. response:" + JSON.toJSONString(addCasterLayoutResponse)); return addCasterLayoutResponse.getBody().getLayoutId(); } /** * Query the layout list of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param layoutId The ID of the layout. * @return DescribeCasterLayoutsResponse The response object for the layout list. * @throws Exception An exception that may be thrown during the API call. */ private DescribeCasterLayoutsResponse describeCasterLayouts(Client client, String casterId, String layoutId) throws Exception { // Construct the request parameters for querying the layout list. DescribeCasterLayoutsRequest describeCasterLayoutsRequest = new DescribeCasterLayoutsRequest(); describeCasterLayoutsRequest.setCasterId(casterId); describeCasterLayoutsRequest.setLayoutId(layoutId); // Call the client API to query the layout list. DescribeCasterLayoutsResponse describeCasterLayoutsResponse = client.describeCasterLayouts(describeCasterLayoutsRequest); System.out.println("Query layout list, return value: " + JSON.toJSONString(describeCasterLayoutsResponse)); return describeCasterLayoutsResponse; } /** * Modify a layout of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio to modify. * @param layoutId The ID of the layout template to apply. * @throws Exception Throws an exception if the API call fails or the parameters are invalid. */ private void modifyCasterLayout(Client client, String casterId, String layoutId) throws Exception { ModifyCasterLayoutRequest modifyCasterLayoutRequest = new ModifyCasterLayoutRequest(); modifyCasterLayoutRequest.setCasterId(casterId); modifyCasterLayoutRequest.setLayoutId(layoutId); modifyCasterLayoutRequest.setBlendList(Arrays.asList("RV02")); modifyCasterLayoutRequest.setMixList(Arrays.asList("RV02")); // Configure the video layer parameters. List<ModifyCasterLayoutRequest.ModifyCasterLayoutRequestVideoLayer> videoLayers = new ArrayList<>(); ModifyCasterLayoutRequest.ModifyCasterLayoutRequestVideoLayer videoLayer = new ModifyCasterLayoutRequest.ModifyCasterLayoutRequestVideoLayer(); videoLayer.setFillMode("fit"); videoLayer.setHeightNormalized(1.0F); videoLayer.setWidthNormalized(1.0F); videoLayer.setPositionRefer("topLeft"); videoLayer.setPositionNormalized(Arrays.asList(0.1F, 0.1F)); videoLayer.setFixedDelayDuration(0); videoLayers.add(videoLayer); modifyCasterLayoutRequest.setVideoLayer(videoLayers); // Configure the audio layer parameters. List<ModifyCasterLayoutRequest.ModifyCasterLayoutRequestAudioLayer> audioLayers = new ArrayList<>(); ModifyCasterLayoutRequest.ModifyCasterLayoutRequestAudioLayer audioLayer = new ModifyCasterLayoutRequest.ModifyCasterLayoutRequestAudioLayer(); audioLayer.setVolumeRate(1.0F); audioLayer.setValidChannel("all"); audioLayer.setFixedDelayDuration(0); audioLayers.add(audioLayer); modifyCasterLayoutRequest.setAudioLayer(audioLayers); // Call the API to modify the production studio layout and output the response. ModifyCasterLayoutResponse modifyCasterLayoutResponse = client.modifyCasterLayout(modifyCasterLayoutRequest); System.out.println("Modify production studio layout. response:" + JSON.toJSONString(modifyCasterLayoutResponse)); } /** * Delete a layout of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio to operate on. * @param layoutId The ID of the layout to delete. * @throws Exception Throws an exception if the delete operation fails. */ private void deleteCasterLayout(Client client, String casterId, String layoutId) throws Exception { // Construct the request parameters for deleting a production studio layout. DeleteCasterLayoutRequest deleteCasterLayoutRequest = new DeleteCasterLayoutRequest(); deleteCasterLayoutRequest.setCasterId(casterId); deleteCasterLayoutRequest.setLayoutId(layoutId); // Call the client interface to perform the delete operation and output the response. DeleteCasterLayoutResponse deleteCasterLayoutResponse = client.deleteCasterLayout(deleteCasterLayoutRequest); System.out.println("Delete production studio layout. response:" + JSON.toJSONString(deleteCasterLayoutResponse)); }Start a production studio.
Sample code
After you create and configure a production studio, you can start the production studio. This way, relevant audio and video processing tasks are started.
Prerequisites
The settings of the production studio are configured, including a domain name and the resolution of output videos.
Related API operations
StartCaster - Start a production studio
NoteAfter you start the production studio, the information about the PVW and PGM scenes is returned, including the scene IDs and information about live streams. You can specify a scene by scene ID.
Sample code
/** * Start a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio to start. * @return StartCasterResponse The response for starting the production studio. * @throws Exception An exception that may be thrown during the startup process. */ private StartCasterResponse startCaster(Client client, String casterId) throws Exception { // Construct the request parameters for starting a production studio. StartCasterRequest startCasterRequest = new StartCasterRequest(); startCasterRequest.setCasterId(casterId); StartCasterResponse startCasterResponse = client.startCaster(startCasterRequest); System.out.println("The production studio is started."); return startCasterResponse; }Update a scene.
Description
After the production studio is started, you can apply the configured layout or components to a specific scene.
Prerequisites
A layout or a component is configured.
A specific scene is created and enabled.
Related API operations
UpdateCasterSceneConfig - Update the configuration of a production studio scene
Sample code
/** * Update the scene configuration of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param sceneId The ID of the scene. * @param layoutId The ID of the layout. * @param componentIds The list of component IDs. * @throws Exception Throws an exception if the API call fails. */ private void updateCasterSceneConfig(Client client, String casterId, String sceneId, String layoutId, List<String> componentIds) throws Exception { // Construct the request object for updating the production studio scene configuration. UpdateCasterSceneConfigRequest updateCasterSceneConfigRequest = new UpdateCasterSceneConfigRequest(); updateCasterSceneConfigRequest.setCasterId(casterId); updateCasterSceneConfigRequest.setSceneId(sceneId); updateCasterSceneConfigRequest.setComponentId(componentIds); updateCasterSceneConfigRequest.setLayoutId(layoutId); // Call the client interface to update the production studio scene configuration. UpdateCasterSceneConfigResponse updateCasterSceneConfigResponse = client.updateCasterSceneConfig(updateCasterSceneConfigRequest); System.out.println("Update production studio scene configuration. response:" + JSON.toJSONString(updateCasterSceneConfigResponse)); }Switch from PVW to PGM.
Description
After the production studio is started, you can apply the layout settings of a PVW scene to a PGM scene.
Prerequisites
A PVW scene is created and enabled.
A PGM scene is created and enabled.
Related API operations
CopyCasterSceneConfig - Copy the configuration of a production studio scene
Sample code
/** * Copy the scene configuration of a production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param fromSceneID The ID of the source scene. * @param toSceneID The ID of the destination scene. * @throws Exception Throws an exception if the copy operation fails. */ private void copyCasterSceneConfig(Client client, String casterId, String fromSceneID, String toSceneID) throws Exception { // Construct the request object for copying the production studio scene configuration. CopyCasterSceneConfigRequest copyCasterSceneConfigRequest = new CopyCasterSceneConfigRequest(); copyCasterSceneConfigRequest.setCasterId(casterId); copyCasterSceneConfigRequest.setFromSceneId(fromSceneID); copyCasterSceneConfigRequest.setToSceneId(toSceneID); // Call the client interface to perform the copy operation and output the result. CopyCasterSceneConfigResponse copyCasterSceneConfigResponse = client.copyCasterSceneConfig(copyCasterSceneConfigRequest); System.out.println("Copy production studio scene configuration. response:" + JSON.toJSONString(copyCasterSceneConfigResponse)); }Enable and disable the PVW mode.
Description
After the production studio is started, you can enable and disable the PVW mode to control the PVW scene. After the PVW scene is disabled, changes on layouts and video sources can be directly applied to the PGM scene.
Prerequisites
A PVW scene is created.
Related API operations
Sample code
/** * Enable the PVW mode. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param pvwSceneId The ID of the scene. * @throws Exception Throws an exception if the API call fails. */ private void startCasterScene(Client client, String casterId, String pvwSceneId) throws Exception { // Construct the request parameters for starting a production studio scene. StartCasterSceneRequest startCasterSceneRequest = new StartCasterSceneRequest(); startCasterSceneRequest.setCasterId(casterId); startCasterSceneRequest.setSceneId(pvwSceneId); // Call the interface to start the production studio scene. StartCasterSceneResponse startCasterSceneResponse = client.startCasterScene(startCasterSceneRequest); System.out.println("Enable the PVW scene. response:" + JSON.toJSONString(startCasterSceneResponse)); } /** * Disable the PVW mode. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param pvwSceneId The ID of the scene. * @throws Exception Throws an exception if the API call fails. */ private void stopCasterScene(Client client, String casterId, String pvwSceneId) throws Exception { // Construct the request parameters for stopping a production studio scene. StopCasterSceneRequest stopCasterSceneRequest = new StopCasterSceneRequest(); stopCasterSceneRequest.setCasterId(casterId); stopCasterSceneRequest.setSceneId(pvwSceneId); // Call the client interface to stop the production studio scene. StopCasterSceneResponse stopCasterSceneResponse = client.stopCasterScene(stopCasterSceneRequest); // Output the response for disabling the PVW scene. System.out.println("Disable the PVW scene. response:" + JSON.toJSONString(stopCasterSceneResponse)); }Switch to a standby resource and switch back to the live stream.
Description
After the production studio is started, you can switch to a standby resource in the PGM scene. You can also switch back to the live stream.
Prerequisites
The production studio is started.
The ID of the standby resource is specified.
Related API operations
EffectCasterUrgent - Switch to the standby resource for a production studio
SetCasterSceneConfig - Set all configurations for a production studio scene
Sample code
/** * Perform an urgent effect switch operation on the production studio to switch the PGM scene to the standby screen. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param pgmSceneId The ID of the PGM scene. * @throws Exception Throws an exception if an error occurs during the API call or execution. */ private void effectCasterUrgent(Client client, String casterId, String pgmSceneId) throws Exception { // Construct the request object for an urgent effect switch. EffectCasterUrgentRequest effectCasterUrgentRequest = new EffectCasterUrgentRequest(); effectCasterUrgentRequest.setCasterId(casterId); effectCasterUrgentRequest.setSceneId(pgmSceneId); // Call the client interface to perform an urgent effect switch. EffectCasterUrgentResponse effectCasterUrgentResponse = client.effectCasterUrgent(effectCasterUrgentRequest); // Output the switch result log. System.out.println("Switch the PGM scene to the standby screen. response: " + JSON.toJSONString(effectCasterUrgentResponse)); } /** * Set the production studio scene configuration to switch back to the live stream. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio. * @param pgmSceneId The ID of the PGM scene. * @param layoutId The ID of the layout. * @throws Exception Throws an exception if the API call fails. */ private void setCasterSceneConfig(Client client, String casterId, String pgmSceneId, String layoutId) throws Exception { // Construct the request object for setting the production studio scene configuration. SetCasterSceneConfigRequest setCasterSceneConfigRequest = new SetCasterSceneConfigRequest(); setCasterSceneConfigRequest.setCasterId(casterId); setCasterSceneConfigRequest.setSceneId(pgmSceneId); setCasterSceneConfigRequest.setLayoutId(layoutId); // To exit standby playback, pass null. To switch to a specified layout, enter the layoutId. // Call the client API to set the production studio scene configuration. SetCasterSceneConfigResponse setCasterSceneConfigResponse = client.setCasterSceneConfig(setCasterSceneConfigRequest); // Output the response. System.out.println("Switch the standby screen to the live screen. response: " + JSON.toJSONString(setCasterSceneConfigResponse)); }Stop a production studio.
Description
After a production studio is started, you can stop the production studio and its audio and video processing tasks.
Prerequisites
The production studio is started.
Related API operations
StopCaster - Stop a production studio
Sample code
/** * Stop the specified production studio. * * @param client An ApsaraVideo Live client instance. * @param casterId The ID of the production studio to stop. * @throws Exception Throws an exception if the operation to stop the production studio fails. */ private void stopCaster(Client client, String casterId) throws Exception { StopCasterRequest request = new StopCasterRequest(); request.setCasterId(casterId); StopCasterResponse response = client.stopCaster(request); System.out.println("Stop the production studio. response: " + JSON.toJSONString(response)); }