# Render user video > The code on this page only works with the **custom UI**. In custom UI mode, the SDK provides multiple options to render user video after a user subscribes to another user's video. After following the steps to render a user's video, each option contains a different type of video stream. - **Single attendee** - A single user's video. - **Active speaker** - A single user's video that automatically updates when the active speaker changes. - **Preview** - A preview of the local user's video. - **Share** - The content being shared by another user. Regardless of which render option you are using, the SDK utilizes four main components. - `MobileRTCVideoView` - The area where the video is rendered. - `MobileRTCVideoViewManager` - An object that sets up the video view. - `MobileRTCVideoUnitRenderInfo` - An object that defines the video's X and Y dimensions. - `ICustomizedVideoSink` - A listener that indicates if a video's subscription fails. ## Subscribe to error data Before subscribing to the video, implement `ICustomizedVideoSink` to know when a video subscription fails. To pass it into the SDK, you'll need a reference to the `MobileRTCVideoView` instance being set up. ```kotlin val videoViewListener = ICustomizedVideoSink { errorCode, size, userId -> // Handle error logic } val videoViewManager = videoView.videoViewManager videoViewManager.addListener(videoViewListener) ``` ```java ICustomizedVideoSink videoViewListener = new ICustomizedVideoSink() { @Override public void onSubscribeUserFail(int errorCode, int size, long userId) { } }; MobileRTCVideoViewManager videoViewManager = videoView.getVideoViewManager(); videoViewManager.addListener(videoViewListener); ``` When you've finished using the video view, remove the listener to avoid leaks. ```kotlin videoViewManager.removeListener(videoViewListener) ``` ```java videoViewManager.removeListener(videoViewListener); ``` ## Define video view The primary user-facing component is `MobileRTCVideoView`. This class extends `FrameLayout`. You can include the view using XML, or programmatically. Include the view in an XML layout with this code. ```xml ``` Or include the view programmatically, similar to typical Android View objects. Create a new `MobileRTCVideoView` instance. ```kotlin val myVideoView = MobileRTCVideoView(context) ``` ```java MobileRTCVideoView myVideoView = new MobileRTCVideoView(context); ``` Get the `MobileRTCVideoView` from the XML layout. ```kotlin val myVideoView = mMainLayoutView.findViewById(R.id.videoView) ``` ```java MobileRTCVideoView myVideoView = mMainLayoutView.findViewById(R.id.videoView); ``` ## Subscribe to video streams Each `MobileRTCVideoView` instance created by the SDK has an associated `MobileRTCVideoViewManager`. Use these to manage the lifecycle of the video subscription rendered on each video view. To obtain a `MobileRTCVideoViewManager` reference, access the `videoViewManager` for the view where video will be rendered. ```kotlin val videoViewManager = videoView.videoViewManager ``` ```java MobileRTCVideoViewManager videoViewManager = videoView.getVideoViewManager(); ``` Before subscribing, create a `MobileRTCVideoUnitRenderInfo` instance to define the video's dimensions. ```kotlin val renderInfo = MobileRTCVideoUnitRenderInfo(xPercent, yPercent, widthPercent, heightPercent) ``` ```java MobileRTCVideoUnitRenderInfo renderInfo = new MobileRTCVideoUnitRenderInfo(xPercent, yPercent, widthPercent, heightPercent); ``` The `videoViewManager` subscribes to a video stream based on the four options listed at the top of the page. To subscribe to a single attendee's video, call `addAttendeeVideoUnit`. This requires the `userId` of the user whose video is being subscribed to. Access this in `InMeetingUserInfo.userId`. Learn how to retrieve a `userId` on [Access in-meeting user info](/docs/meeting-sdk/android/default-ui/basic-features/in-meeting-user-info/). ```kotlin videoViewManager.addAttendeeVideoUnit(userId, renderInfo) ``` ```java videoViewManager.addAttendeeVideoUnit(userId, renderInfo); ``` To subscribe to the active speaker stream, call `addActiveVideoUnit`. ```kotlin videoViewManager.addActiveVideoUnit(renderInfo) ``` ```java videoViewManager.addActiveVideoUnit(renderInfo); ``` To subscribe to the local preview of the user associated with this SDK instance, call `addPreviewVideoUnit`. ```kotlin videoViewManager.addPreviewVideoUnit(renderInfo) ``` ```java videoViewManager.addPreviewVideoUnit(renderInfo); ``` To subscribe to the video being shared by another user, call `addShareVideoUnit`. To keep listening to the current sharing status and know when to subscribe to the shared view, use the `onSharingStatus` callback from `InMeetingShareController.InMeetingShareListener`. ```kotlin videoViewManager.addShareVideoUnit(userId, renderInfo) ``` ```java videoViewManager.addShareVideoUnit(userId, renderInfo); ``` ## Manage existing video streams While an attendee's video subscription is active, it can be updated to resubscribe to another user. To update the attendee's video unit with a new user or size, call `updateAttendeeVideoUnit`. ```kotlin videoViewManager.updateAttendeeVideoUnit(userId, renderInfo) ``` ```java videoViewManager.updateAttendeeVideoUnit(userId, renderInfo); ``` To resize any other type of video unit, use the update methods providing only the render info. ```kotlin videoViewManager.updatePreviewVideoUnit(renderInfo) videoViewManager.updateShareVideoUnit(renderInfo) videoViewManager.updateActiveVideoUnit(renderInfo) ``` ```java videoViewManager.updatePreviewVideoUnit(renderInfo); videoViewManager.updateShareVideoUnit(renderInfo); videoViewManager.updateActiveVideoUnit(renderInfo); ``` Finally, when a video unit is no longer being used, end the subscription with the method associated with the type of video unit. ```kotlin videoViewManager.removeActiveVideoUnit() videoViewManager.removeAllAttendeeVideoUnit() videoViewManager.removeAttendeeVideoUnit(userId) videoViewManager.removePreviewVideoUnit() videoViewManager.removeShareVideoUnit() ``` ```java videoViewManager.removeActiveVideoUnit(); videoViewManager.removeAllAttendeeVideoUnit(); videoViewManager.removeAttendeeVideoUnit(userId); videoViewManager.removePreviewVideoUnit(); videoViewManager.removeShareVideoUnit(); ```