Canvas
This class provides methods for video rendering.
public class Canvas { public Canvas(Rte rte, CanvasInitialConfig config); public void addView(View view, ViewConfig viewConfig) throws RteException; public void removeView(View view, ViewConfig viewConfig) throws RteException; public void getConfigs(CanvasConfig config) throws RteException; public void setConfigs(CanvasConfig config) throws RteException; }
- Since
- v4.5.0
Method
- Canvas
- Creates a Canvas object. See Canvas.
- setConfigs [3/3]
- Sets the vide render mode. See setConfigs [3/3].
- getConfigs [3/3]
- Gets the current video render mode. See getConfigs [3/3].
- AddView
- Adds a view. See AddView.
- removeView
- Removes a view. See removeView.
AddView
Adds a view to be rendered.
public void addView(View view, ViewConfig viewConfig) throws RteException;
- Since
- v4.5.0
Applicable scenarios
When you need to use a player to play a video, you can call this method to add a view to the video renderer for displaying.
Call timing
Call this method after setCanvas.
Restrictions
Only one view can be added.
Parameters
- view
- SurfaceView object.
- config
- The configuration of View object. Currently, you need to set it to null.
Exception
If the method call fails, the SDK throws RteException and returns an error message. You need to catch the exception and handle it.
getConfigs [3/3]
Gets the current video rendering configuration of the player.
public void getConfigs(CanvasConfig config) throws RteException;
- Since
- v4.5.0
Call timing
Call this method after Canvas.
Restrictions
None.
Parameters
- config
- Canvas object settings. See CanvasConfig.
Exception
If the method call fails, the SDK throws RteException and returns an error message. You need to catch the exception and handle it.
removeView
Removes a view.
public void removeView(View view, ViewConfig viewConfig) throws RteException;
- Since
- v4.5.0
After you call AddView to add a view, if you need to remove the view, you can call this method.
Call timing
Call this method after AddView.
Restrictions
Only one view can be removed at a time.
Parameters
- view
- View object to be removed.
- config
- The configuration of View object. Currently, you need to set it to null.
Exception
If the method call fails, the SDK throws RteException and returns an error message. You need to catch the exception and handle it.
setConfigs [3/3]
Sets the video rendering configuration of the player.
public void setConfigs(CanvasConfig config) throws RteException;
- Since
- v4.5.0
Call timing
Call this method after openWithUrl.
Restrictions
None.
Parameters
- config
- Canvas object settings. See CanvasConfig.
Exception
If the method call fails, the SDK throws RteException and returns an error message. You need to catch the exception and handle it.