Skip to content

Instantly share code, notes, and snippets.

@skydoves
Last active February 23, 2023 04:41
Show Gist options
  • Save skydoves/1e5fa46deb14b6d4a9483ee36cd149c0 to your computer and use it in GitHub Desktop.
Save skydoves/1e5fa46deb14b6d4a9483ee36cd149c0 to your computer and use it in GitHub Desktop.
video_call_screen
// 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