BaseVideoRenderer

public abstract class BaseVideoRenderer

Defines a video renderer to be used by a PublisherKit object or a SubscriberKit object.

Nested types: BaseVideoRenderer.Frame

Properties

Name Type Description
STYLE_VIDEO_SCALE String static final A value for the key parameter of the setStyle(String key, String value), SubscriberKit#setStyle(String key, String value), and PublisherKit#setStyle(String key, String value) methods, used to determine the scaling of the video. Valid values for this key are BaseVideoRenderer.STYLE_VIDEO_FILL (the video scales to fill the entire area of the renderer, with cropping as needed) and BaseVideoRenderer.STYLE_VIDEO_FIT (the video shrinks, as needed, so that the entire video is visible with pillarboxing). Constant value: STYLE_VIDEO_SCALE
STYLE_VIDEO_FILL String static final A value for the STYLE_VIDEO_SCALE style, specifying that the video scales to fill the entire area of the renderer, with cropping as needed). Constant value: STYLE_VIDEO_FILL
STYLE_VIDEO_FIT String static final A value for the STYLE_VIDEO_SCALE style, specifying that the video shrinks, as needed, so that the entire video is visible with pillarboxing. Constant value: STYLE_VIDEO_FIT

Methods

Name Description
BaseVideoRenderer()
getView() → {View} Returns the View containing the video.
onFrame(frame) Called when a frame is rendered for the stream.
onPause() Call this method when the activity pauses.
onResume() Call this method when the activity resumes.
onVideoPropertiesChanged(videoEnabled) Called when the stream changes between having video and not having video (audio-only).
setStyle(key, value) Set a style for this video renderer.

BaseVideoRenderer()

getView() → {View}

Returns the View containing the video.

Returns:

View

onFrame(frame)

Called when a frame is rendered for the stream. Do not call any OpenTok API methods (except those in the Frame class) on the same thread that invokes this callback. If you need to call an OpenTok API method (for example, PublisherKit or SubscriberKit methods), reschedule its execution to a different thread.

Parameters:
Name Type Description
frame BaseVideoRenderer.Frame The video frame. Call the getBuffer method of this object to get the frame data, which is in I420 format.

onPause()

Call this method when the activity pauses. When you override this method, implement code to respond to the activity being paused. For example, you may pause rendering audio or video.

See: : - onResume()

onResume()

Call this method when the activity resumes. When you override this method, implement code to respond to the activity being resumed. For example, you may resume rendering audio or video.

See: : - onPause()

onVideoPropertiesChanged(videoEnabled)

Called when the stream changes between having video and not having video (audio-only).

Parameters:
Name Type Description
videoEnabled boolean Whether the stream has video (true) or not (false).

setStyle(key, value)

Set a style for this video renderer. By default, there is only one pre-defined style key: BaseVideoRenderer#STYLE_VIDEO_SCALE. You can set a value for this key to determine the scaling of the video. The following values are supported:

You can extend this class and override this method to support other styles and behaviors.

Parameters:
Name Type Description
key String The style to set.
value String The value you are setting the style to.