This topic walks you through building a production studio with the ApsaraVideo Live API. Each step includes a Java code sample and links to the relevant API reference.
Usage notes
This guide covers the API-based approach, which requires you to develop a frontend web page for user interaction. This is different from using the production studios in the ApsaraVideo Live console.
If you prefer a no-code solution, use the production studios in the console. For more information, see Get started with a production studio.
Prerequisites
Before you begin, ensure that you have:
The production studio feature enabled and a streaming domain name configured. For more information, see Create and manage production studios.
The ApsaraVideo Live SDK for Java installed. For setup instructions, see Use the server SDK for Java.
Procedure
Configure a production studio.
Description
After you create a production studio, configure its settings such as the domain name, transcoding, recording, and standby resource.
API operation
Sample code
/** * Configure a production studio. * * @param client An instance of the ApsaraVideo Live client. * @param casterId The ID of the production studio. * @throws Exception Throws an exception if a fault occurs during the configuration procedure. */ private void setCasterConfig(Client client, String casterId) throws Exception { SetCasterConfigRequest request = new SetCasterConfigRequest(); request.setCasterId(casterId); // Set the streaming domain name. request.setDomainName("domainName"); // Configure transcoding settings. JSONObject transcodeConfig = new JSONObject(); // Live stream transcoding template IDs. Options: lsd (SD), lld (LD), lud (UHD), lhd (HD adaptive), daobo-lsd (SD), daobo-lld (LD), daobo-lud (UHD), daobo-lhd (HD). JSONObject liveTemplateIds = new JSONObject(); JSONArray locationId = new JSONArray(); locationId.add("lld"); liveTemplateIds.put("LocationId", locationId); transcodeConfig.put("LiveTemplateIds", liveTemplateIds); // Production studio transcoding template IDs. Options: lp_ld (LD), lp_sd (SD), lp_hd (HD), lp_ud (UHD), lp_ld_v (vertical LD), lp_sd_v (vertical SD), lp_hd_v (vertical HD), lp_ud_v(vertical UHD). transcodeConfig.put("CasterTemplate", "lp_sd"); request.setTranscodeConfig(transcodeConfig.toJSONString()); // Configure recording settings. 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 for output. Live streams and on-demand videos are supported.
API operations
Sample code
/** * Adds a video source to the specified production studio. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID that specifies the production studio to which the video source will be added * @return Returns the resource ID of the added video source * @throws Exception Thrown when 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(""); // Sets the number of replays, with an optional range of [-1,60]. The default value is 0, which means no replay; -1 indicates infinite loop. addCasterVideoResourceRequest.setRepeatNum(-1); AddCasterVideoResourceResponse addCasterVideoResourceResponse = client.addCasterVideoResource(addCasterVideoResourceRequest); System.out.println("Add video source: response: " + JSON.toJSONString(addCasterVideoResourceResponse)); return addCasterVideoResourceResponse.getBody().getResourceId(); } /** * Queries the list of video source resources for the specified production studio. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID used to identify the production studio to query * @return DescribeCasterVideoResourcesResponse Response object containing the video source resource list * @throws Exception Exception that may be thrown during the API call process */ 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; } /** * Modifies a production studio video resource. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param resourceId Resource ID * @throws Exception Thrown when 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)); } /** * Deletes a video source. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param resourceId Resource ID * @throws Exception Thrown when 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. Supported components include text and images.
API operations
NoteYou must configure the following information about components:
If the component is text, set the properties such as text content, font, and color.
If the component is an image, specify the ID of the image.
Sample code
/** * Adds a text component to the specified production studio. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @return The unique identifier of the newly added component (ComponentId) * @throws Exception If an error occurs during the request */ private String addCasterComponent(Client client, String casterId) throws Exception { // Construct the component layer parameters: set the component's dimensions and position on 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(); // Component TextLayerContent 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 to add a component and set related parameters AddCasterComponentRequest addCasterComponentRequest = new AddCasterComponentRequest(); // Set component element properties addCasterComponentRequest.setCasterId(casterId); // Specifies the component position. You can assign at most one component to each position. The format must conform to "RC01~RC99". addCasterComponentRequest.setLocationId("RC01"); // Component name addCasterComponentRequest.setComponentName("testComponentName"); // Component type. Valid values: text (text component; you must also specify the TextLayerContent request parameter), image (image component; you must also specify the ImageLayerContent request parameter), caption (caption component; you must also specify the CaptionLayerContent request parameter). addCasterComponentRequest.setComponentType("text"); addCasterComponentRequest.setTextLayerContent(textLayerContent.toJSONString()); // Effect applied to the component. Valid values: none (default; no effect), animateH (horizontal scrolling), animateV (vertical scrolling). addCasterComponentRequest.setEffect("animateH"); // Dimensions 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 newly added component return addCasterComponentResponse.getBody().getComponentId(); } /** * Queries the list of components in a production studio. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID, used to specify the production studio to query * @param componentId Component ID, used to specify the specific component to query * @return DescribeCasterComponentsResponse Response object for the component list * @throws 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 to query the list of components in a 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; } /** * Updates a production studio component. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param componentId Component ID * @throws 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(); // Component TextLayerContent 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 component element properties 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)); } /** * Deletes a production studio component. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param componentId Component ID * @throws Exception An exception that may be thrown during the deletion operation */ private void deleteCasterComponent(Client client, String casterId, String componentId) throws Exception { // Construct the request object to delete a component and set parameters DeleteCasterComponentRequest deleteCasterComponentRequest = new DeleteCasterComponentRequest(); deleteCasterComponentRequest.setCasterId(casterId); deleteCasterComponentRequest.setComponentId(componentId); // Call the client interface to perform the deletion 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 added in a layout.
API operations
Sample code
/** * Adds a production studio layout. * * @param client An instance of the ApsaraVideo Live client. * @param casterId The ID of the production studio to manage. * @return The ID of the newly created layout. * @throws Exception is thrown if the API call fails or other exceptions occur. */ private String addCasterLayout(Client client, String casterId) throws Exception { // Create an AddCasterLayoutRequest object and set the basic parameters. AddCasterLayoutRequest addCasterLayoutRequest = new AddCasterLayoutRequest(); addCasterLayoutRequest.setCasterId(casterId); addCasterLayoutRequest.setBlendList(Arrays.asList("RV01")); addCasterLayoutRequest.setMixList(Arrays.asList("RV01")); // Configure the parameters for the video layers. 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 parameters for the audio layers. 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 the production studio layout. AddCasterLayoutResponse addCasterLayoutResponse = client.addCasterLayout(addCasterLayoutRequest); System.out.println("Add production studio layout. response:" + JSON.toJSONString(addCasterLayoutResponse)); return addCasterLayoutResponse.getBody().getLayoutId(); } /** * Queries the list of production studio layouts. * * @param client An instance of the ApsaraVideo Live client. * @param casterId The ID of the production studio. * @param layoutId The ID of the layout. * @return DescribeCasterLayoutsResponse The response object that contains the list of layouts. * @throws Exception is thrown if the API call fails. */ private DescribeCasterLayoutsResponse describeCasterLayouts(Client client, String casterId, String layoutId) throws Exception { // Create a request to query the list of layouts. DescribeCasterLayoutsRequest describeCasterLayoutsRequest = new DescribeCasterLayoutsRequest(); describeCasterLayoutsRequest.setCasterId(casterId); describeCasterLayoutsRequest.setLayoutId(layoutId); // Call the client API to query the list of layouts. DescribeCasterLayoutsResponse describeCasterLayoutsResponse = client.describeCasterLayouts(describeCasterLayoutsRequest); System.out.println("Query the list of layouts. Return value:" + JSON.toJSONString(describeCasterLayoutsResponse)); return describeCasterLayoutsResponse; } /** * Modifies a production studio layout. * * @param client An instance of the ApsaraVideo Live client. * @param casterId The ID of the production studio to modify. * @param layoutId The ID of the layout template to apply. * @throws Exception is thrown 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 parameters for the video layers. 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 parameters for the audio layers. 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 print the response. ModifyCasterLayoutResponse modifyCasterLayoutResponse = client.modifyCasterLayout(modifyCasterLayoutRequest); System.out.println("Modify production studio layout. response:" + JSON.toJSONString(modifyCasterLayoutResponse)); } /** * Deletes a production studio layout. * * @param client An instance of the ApsaraVideo Live client. * @param casterId The ID of the production studio to manage. * @param layoutId The ID of the layout to delete. * @throws Exception is thrown if the deletion fails. */ private void deleteCasterLayout(Client client, String casterId, String layoutId) throws Exception { // Create a request to delete a production studio layout. DeleteCasterLayoutRequest deleteCasterLayoutRequest = new DeleteCasterLayoutRequest(); deleteCasterLayoutRequest.setCasterId(casterId); deleteCasterLayoutRequest.setLayoutId(layoutId); // Call the client API to delete the layout and print 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 it. 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.
API operation
NoteAfter you start the production studio, the information about the PVW and PGM scenes is returned, including the scene IDs and information about streams. You can specify a scene by scene ID.
Sample code
/** * Starts the production studio. * * @param client The ApsaraVideo Live client instance. * @param casterId The ID of the production studio to start. * @return StartCasterResponse The response of the StartCaster operation. * @throws Exception The exception that may be thrown during the process. */ private StartCasterResponse startCaster(Client client, String casterId) throws Exception { // Construct the request to start the production studio. StartCasterRequest startCasterRequest = new StartCasterRequest(); startCasterRequest.setCasterId(casterId); StartCasterResponse startCasterResponse = client.startCaster(startCasterRequest); System.out.println("Production studio started successfully."); 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.
API operation
Sample code
/** * Updates the configuration of a production studio scenario. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param sceneId Scenario ID * @param layoutId Layout ID * @param componentIds List of component IDs * @throws Exception Throws Exception if the API call fails */ private void updateCasterSceneConfig(Client client, String casterId, String sceneId, String layoutId, List<String> componentIds) throws Exception { // Constructs the request object to update the production studio scenario configuration UpdateCasterSceneConfigRequest updateCasterSceneConfigRequest = new UpdateCasterSceneConfigRequest(); updateCasterSceneConfigRequest.setCasterId(casterId); updateCasterSceneConfigRequest.setSceneId(sceneId); updateCasterSceneConfigRequest.setComponentId(componentIds); updateCasterSceneConfigRequest.setLayoutId(layoutId); // Calls the client API to update the production studio scenario configuration UpdateCasterSceneConfigResponse updateCasterSceneConfigResponse = client.updateCasterSceneConfig(updateCasterSceneConfigRequest); System.out.println("Updated production studio scenario 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.
API operations
Sample code
/** * Copy production studio scene configuration * * @param client Alibaba Cloud ApsaraVideo Live client instance * @param casterId production studio ID * @param fromSceneID source scene ID * @param toSceneID target scene ID * @throws Exception throws an exception when the copy operation fails */ private void copyCasterSceneConfig(Client client, String casterId, String fromSceneID, String toSceneID) throws Exception { // Construct a request object to copy production studio scene configuration CopyCasterSceneConfigRequest copyCasterSceneConfigRequest = new CopyCasterSceneConfigRequest(); copyCasterSceneConfigRequest.setCasterId(casterId); copyCasterSceneConfigRequest.setFromSceneId(fromSceneID); copyCasterSceneConfigRequest.setToSceneId(toSceneID); // Call the client interface to execute 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 PVW scene is disabled, changes on layouts and video sources can be directly applied to the PGM scene.
Prerequisites
A PVW scene is created.
API operations
Sample code
/** * Start preview * * @param client The ApsaraVideo Live client instance * @param casterId The production studio ID * @param pvwSceneId The scene ID * @throws Exception Throws an exception if the API call fails. */ private void startCasterScene(Client client, String casterId, String pvwSceneId) throws Exception { // Construct the request to start the production studio scene. StartCasterSceneRequest startCasterSceneRequest = new StartCasterSceneRequest(); startCasterSceneRequest.setCasterId(casterId); startCasterSceneRequest.setSceneId(pvwSceneId); // Call the API to start the production studio scene. StartCasterSceneResponse startCasterSceneResponse = client.startCasterScene(startCasterSceneRequest); System.out.println("Start the PVW scene for preview. Response:" + JSON.toJSONString(startCasterSceneResponse)); } /** * Stop preview * * @param client The ApsaraVideo Live client instance * @param casterId The production studio ID * @param pvwSceneId The scene ID * @throws Exception Throws an exception if the API call fails. */ private void stopCasterScene(Client client, String casterId, String pvwSceneId) throws Exception { // Construct the request to stop the production studio scene. StopCasterSceneRequest stopCasterSceneRequest = new StopCasterSceneRequest(); stopCasterSceneRequest.setCasterId(casterId); stopCasterSceneRequest.setSceneId(pvwSceneId); // Call the client API to stop the production studio scene. StopCasterSceneResponse stopCasterSceneResponse = client.stopCasterScene(stopCasterSceneRequest); // Print the response for stopping the PVW scene for preview. System.out.println("Stop the PVW scene for preview. Response:" + JSON.toJSONString(stopCasterSceneResponse)); }Switch to and back from a standby resource
Description
After the production studio is started, you can switch to a standby resource in the PGM scene and switch back.
Prerequisites
The production studio is started.
The ID of the standby resource is specified.
API operations
Sample code
/** * Switches the PGM scene to the backup broadcast feed. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param pgmSceneId PGM scene ID * @throws Exception if an exception occurs during the API call or execution */ private void effectCasterUrgent(Client client, String casterId, String pgmSceneId) throws Exception { // Constructs the request object for switching effects urgently EffectCasterUrgentRequest effectCasterUrgentRequest = new EffectCasterUrgentRequest(); effectCasterUrgentRequest.setCasterId(casterId); effectCasterUrgentRequest.setSceneId(pgmSceneId); // Calls the client API to switch effects urgently EffectCasterUrgentResponse effectCasterUrgentResponse = client.effectCasterUrgent(effectCasterUrgentRequest); // Logs the switching result System.out.println("Switched the PGM scene to the backup broadcast feed. Response: " + JSON.toJSONString(effectCasterUrgentResponse)); } /** * Configures the production studio scene to switch back to the live broadcast feed. * * @param client ApsaraVideo Live client instance * @param casterId Production studio ID * @param pgmSceneId PGM scene ID * @param layoutId Layout ID * @throws Exception if the API call fails */ private void setCasterSceneConfig(Client client, String casterId, String pgmSceneId, String layoutId) throws Exception { // Constructs the request object for configuring the production studio scene SetCasterSceneConfigRequest setCasterSceneConfigRequest = new SetCasterSceneConfigRequest(); setCasterSceneConfigRequest.setCasterId(casterId); setCasterSceneConfigRequest.setSceneId(pgmSceneId); setCasterSceneConfigRequest.setLayoutId(layoutId); // Pass null to exit the backup broadcast feed; pass a layout ID to switch to the specified layout. // Calls the client API to configure the production studio scene SetCasterSceneConfigResponse setCasterSceneConfigResponse = client.setCasterSceneConfig(setCasterSceneConfigRequest); // Logs the response System.out.println("Switched the backup broadcast feed to the live broadcast feed. 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.
API operations
Sample code
/** * Stops the specified production studio. * * @param client The ApsaraVideo Live client instance. * @param casterId The ID of the production studio to stop. * @throws Exception Thrown 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("StopCaster response: " + JSON.toJSONString(response)); }