Agora Java API Reference for Android

Public Member Functions | Protected Member Functions | List of all members
io.agora.rte.Canvas Class Reference

## Public Member Functions
| Canvas (Rte rte, CanvasInitialConfig config)
long | getNativeHandle ()
void | addView (View view, ViewConfig viewConfig) throws RteException
| Adds a rendering view. More...
void | removeView (View view, ViewConfig viewConfig) throws RteException
| Removes a rendering view. More...
void | getConfigs (CanvasConfig config) throws RteException
| Gets the current video rendering configuration of the player. More...
void | setConfigs (CanvasConfig config) throws RteException
| Sets the video rendering configuration for the player. More...

## Protected Member Functions
void | finalize ()

## Detailed Description

Canvas interface, used to set the video rendering view.

Since
  v4.4.0

## Constructor & Destructor Documentation

## ◆ Canvas()

io.agora.rte.Canvas.Canvas | ( | Rte | rte,
|  | CanvasInitialConfig | config
| ) |  |

Construct a Canvas object.

Since
  v4.4.0

Parameters

  rte | Rte object.
  config | CanvasInitialConfig initialization configuration object. Currently, a null pointer can be passed.

## Member Function Documentation

## ◆ addView()

void io.agora.rte.Canvas.addView | ( | View | view,
|  | ViewConfig | viewConfig
| ) |  | throws RteException

Adds a rendering view.

Since
  v4.4.0

Applicable scenarios: When you need to play a video using the player, you can call this method to add a view to the video renderer in order to display the video content. Call timing: You must call this method before `setCanvas`.

Note
  Currently, only one view is supported.

Parameters

  view | A `SurfaceView` object.
  config | The settings for the `View` object. Pass null for now.

Exceptions

  RteException | If the method call fails, the SDK throws an `RteException` with the corresponding error information. You need to catch and handle the exception.

## ◆ removeView()

void io.agora.rte.Canvas.removeView | ( | View | view,
|  | ViewConfig | viewConfig
| ) |  | throws RteException

Removes a rendering view.

Since
  v4.4.0

After you call `AddView` to add a view, you can call this method to remove the rendering view. Call timing: This method must be called after `AddView`.

Note
  Only one view can be removed at a time.

Parameters

  view | The view object to be removed.
  config | The settings of the `View` object. Pass null for now.

Exceptions

  RteException | If the method call fails, the SDK throws an `RteException` with the corresponding error information. You need to catch and handle the exception.

## ◆ getConfigs()

void io.agora.rte.Canvas.getConfigs | ( | CanvasConfig | config | ) | throws RteException

Gets the current video rendering configuration of the player.

Since
  v4.4.0

Call timing: You must call this method after `Canvas`.

Parameters

  config | Settings of the `Canvas` object. See `CanvasConfig` for details.

Exceptions

  RteException | If the method call fails, the SDK throws an `RteException` with the corresponding error information. You need to catch and handle the exception.

## ◆ setConfigs()

void io.agora.rte.Canvas.setConfigs | ( | CanvasConfig | config | ) | throws RteException

Sets the video rendering configuration for the player.

Since
  v4.4.0

Call timing: You must call this method before `openWithUrl`.

Parameters

  config | Settings for the `Canvas` object. See `CanvasConfig` for details.

Exceptions

  RteException | If the method call fails, the SDK throws an `RteException` with the corresponding error information. You need to catch and handle the exception.