Is there a flag to check if the video is visible to user or not

Hello,

We are developing where only host video and shared screen is available. We are using these below listed callbacks to implement this:

  • onMeetingActiveVideo
  • onSharingStatus
  • onMeetingStatusChanged (meetingStatus == MEETING_STATUS_INMEETING)

On trigger from anyone of these callbacks we execute this code:

private fun refreshActiveScreen(userId: Long) {
        val videoManager = mobileRTCVideoView.videoViewManager

        videoManager?.removeAllVideoUnits()

        if (viewModel.isOtherUserSharing())
            videoManager?.addShareVideoUnit(userId, activeRenderInfo)
        else videoManager?.addAttendeeVideoUnit(userId, activeRenderInfo)
    }

But the problem is that these callbacks are not reliable as they gets triggered multiple times. Which leads the screen to go black and live multiple times. Is this anyway for me to know what is visible to user through “mobileRTCVideoView.videoViewManager” or some other type of check without resorting to boolean flags?

Hi @rahul.mishra,

It sounds like the main issue here is that you are trying to subscribe to video streams repeatedly, even if there is no change to the stream you would like to display. The easiest way to solve this would be to add some state management within your implementation, since MobileRTCVideoView does not expose this information.

One easy way to do this would be to declare an isShareVisible boolean and update your method to something like this:

private fun refreshActiveScreen(userId: Long) {
    val videoManager = mobileRTCVideoView.videoViewManager

    videoManager?.removeAllVideoUnits()

    if (viewModel.isOtherUserSharing() && !isShareVisible) {
        isShareVisible = true
        videoManager?.addShareVideoUnit(userId, activeRenderInfo)
    } else if (isShareVisible) {
        isShareVisible = false
        videoManager?.addAttendeeVideoUnit(userId, activeRenderInfo)
    }
}

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.