fun bindVideoTile()

in app/src/main/java/com/amazonaws/services/chime/sdkdemo/adapter/VideoAdapter.kt [108:186]


    fun bindVideoTile(videoCollectionTile: VideoCollectionTile) {
        audioVideo.bindVideoView(binding.videoSurface, videoCollectionTile.videoTileState.tileId)
        // Save the bound VideoRenderView in order to explicitly control the visibility of SurfaceView.
        // This is to bypass the issue where we cannot hide a SurfaceView that overlaps with another one.
        videoCollectionTile.videoRenderView = binding.videoSurface
        videoCollectionTile.pauseMessageView = binding.poorConnectionMessage

        if (videoCollectionTile.videoTileState.isContent) {
            binding.videoSurface.contentDescription = "ScreenTile"
        } else {
            binding.videoSurface.contentDescription = "${videoCollectionTile.attendeeName} VideoTile"
        }
        if (videoCollectionTile.videoTileState.isLocalTile) {
            binding.onTileButton.setImageResource(R.drawable.ic_switch_camera)
            binding.attendeeName.visibility = View.GONE
            binding.onTileButton.visibility = View.VISIBLE

            if (SegmentationProcessor.isMachineLearningLibraryLoaded) {
                binding.videoFilterButton.setImageResource(R.drawable.button_more)
                binding.videoFilterButton.visibility = View.VISIBLE
            } else {
                binding.videoFilterButton.visibility = View.INVISIBLE
            }
            // To facilitate demoing and testing both use cases, we account for both our external
            // camera and the camera managed by the facade. Actual applications should
            // only use one or the other
            updateLocalVideoMirror()
            binding.onTileButton.setOnClickListener {
                if (audioVideo.getActiveCamera() != null) {
                    audioVideo.switchCamera()
                } else {
                    cameraCaptureSource?.switchCamera()
                }
                updateLocalVideoMirror()
            }
            if (SegmentationProcessor.isMachineLearningLibraryLoaded) {
                binding.videoFilterButton.setOnClickListener {
                    showVideoFilterPopup(binding.videoFilterButton)
                }
            }
        } else {
            binding.videoSurface.mirror = false
            binding.attendeeName.text = videoCollectionTile.attendeeName
            binding.attendeeName.visibility = View.VISIBLE
            binding.onTileButton.visibility = View.VISIBLE
            binding.videoFilterButton.visibility = View.INVISIBLE
            when (videoCollectionTile.videoTileState.pauseState) {
                VideoPauseState.Unpaused ->
                    binding.onTileButton.setImageResource(R.drawable.ic_pause_video)
                VideoPauseState.PausedByUserRequest ->
                    binding.onTileButton.setImageResource(R.drawable.ic_resume_video)
                VideoPauseState.PausedForPoorConnection ->
                    binding.poorConnectionMessage.visibility = View.VISIBLE
            }

            binding.onTileButton.setOnClickListener {
                val tileId = videoCollectionTile.videoTileState.tileId
                if (videoCollectionTile.videoTileState.pauseState == VideoPauseState.Unpaused) {
                    audioVideo.pauseRemoteVideoTile(tileId)
                    meetingModel.userPausedVideoTileIds.add(tileId)
                    binding.onTileButton.setImageResource(R.drawable.ic_resume_video)
                } else {
                    audioVideo.resumeRemoteVideoTile(tileId)
                    meetingModel.userPausedVideoTileIds.remove(tileId)
                    binding.onTileButton.setImageResource(R.drawable.ic_pause_video)
                }
            }

            binding.videoSurface.setOnClickListener {
                val attendeeId = videoCollectionTile.videoTileState.attendeeId
                showPriorityPopup(binding.onTileButton, attendeeId)
            }
        }

        binding.videoConfigButton.setOnClickListener {
            val attendeeId = videoCollectionTile.videoTileState.attendeeId
            showResolutionPopup(binding.videoConfigButton, attendeeId)
        }
    }