We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTCMTLVideoView can't be filled with UIKitView components or Box components
Box( modifier = modifier.fillMaxWidth().aspectRatio(16f/9f) .clickable( interactionSource = interactionSource, indication = null, onClick = { } ), contentAlignment = Alignment.Center ) { remoteVideoTrack?.let { Box(modifier = Modifier.matchParentSize().onGloballyPositioned { layoutCoordinates -> val width = layoutCoordinates.size.width val height = layoutCoordinates.size.height log.v{ "remoteVideoTrack Width: $width, Height: $height" } }) { Video( videoTrack = it, audioTrack = remoteAudioTrack, modifier = Modifier.fillMaxSize().onGloballyPositioned { layoutCoordinates -> val width = layoutCoordinates.size.width val height = layoutCoordinates.size.height log.v{ "Video Width: $width, Height: $height" }} ) } }?: Box(modifier = Modifier.matchParentSize().background(Color.Black).onGloballyPositioned { layoutCoordinates -> val width = layoutCoordinates.size.width val height = layoutCoordinates.size.height log.v{ "Init Box Width: $width, Height: $height" } }) { } } @OptIn(ExperimentalForeignApi::class) @Composable actual fun Video(videoTrack: VideoStreamTrack, modifier: Modifier, audioTrack: AudioStreamTrack?) { UIKitView( factory = { RTCMTLVideoView().apply { videoContentMode = UIViewContentMode.UIViewContentModeScaleToFill videoTrack.addRenderer(this) } }, modifier = modifier, onRelease = { videoTrack.removeRenderer(it) } ) }
NSLayoutConstraint.activateConstraints(listOf( widthAnchor.constraintEqualToConstant(1290.toDp().value.toDouble()), // 设置宽度 heightAnchor.constraintEqualToConstant(726.toDp().value.toDouble()) // 设置高度 ))
UIKitView( factory = { RTCMTLVideoView().apply { translatesAutoresizingMaskIntoConstraints = false videoContentMode = UIViewContentMode.UIViewContentModeScaleToFill videoTrack.addRenderer(this) dispatch_async(dispatch_get_main_queue()) { if (superview != null) { log.v("superview is not null") NSLayoutConstraint.activateConstraints(listOf( leadingAnchor.constraintEqualToAnchor(superview!!.leadingAnchor), trailingAnchor.constraintEqualToAnchor(superview!!.trailingAnchor), topAnchor.constraintEqualToAnchor(superview!!.topAnchor), bottomAnchor.constraintEqualToAnchor(superview!!.bottomAnchor) )) } else { log.v("superview is null") } } } }, modifier = modifier, onRelease = { videoTrack.removeRenderer(it) } )
Can you help me modify the above logic to make it adaptive and fill the parent view?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
BUG Question
RTCMTLVideoView can't be filled with UIKitView components or Box components
RTCMTLVideoView should be filled with UIKitView components, that is, the length and height should be the same
Situation 1: This manual setting can fill the entire parent view, but intercepts the captured video content.
Situation 2: The actual operating effect is that there is a blank space and the Box is not filled as expected.
Can you help me modify the above logic to make it adaptive and fill the parent view?
The text was updated successfully, but these errors were encountered: