-
-
Save skydoves/1e5fa46deb14b6d4a9483ee36cd149c0 to your computer and use it in GitHub Desktop.
video_call_screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2023 Stream.IO, Inc. All Rights Reserved. | |
// SPDX-License-Identifier: Apache-2.0 | |
@Composable | |
fun VideoCallScreen() { | |
val sessionManager = LocalWebRtcSessionManager.current | |
LaunchedEffect(key1 = Unit) { | |
sessionManager.onSessionScreenReady() | |
} | |
Box( | |
modifier = Modifier.fillMaxSize() | |
) { | |
var parentSize: IntSize by remember { mutableStateOf(IntSize(0, 0)) } | |
val remoteVideoTrackState by sessionManager.remoteVideoTrackFlow.collectAsState(null) | |
val remoteVideoTrack = remoteVideoTrackState | |
val localVideoTrackState by sessionManager.localVideoTrackFlow.collectAsState(null) | |
val localVideoTrack = localVideoTrackState | |
if (remoteVideoTrack != null) { | |
VideoRenderer( | |
videoTrack = remoteVideoTrack, | |
modifier = Modifier | |
.fillMaxSize() | |
.onSizeChanged { parentSize = it } | |
) | |
} | |
if (localVideoTrack != null) { | |
FloatingVideoRenderer( | |
modifier = Modifier | |
.size(width = 150.dp, height = 210.dp) | |
.clip(RoundedCornerShape(16.dp)) | |
.align(Alignment.TopEnd), | |
videoTrack = localVideoTrack, | |
parentBounds = parentSize, | |
paddingValues = PaddingValues(0.dp) | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment