-
-
Save Arunshaik2001/fbdf14f741af08dd8515e32f769b475a to your computer and use it in GitHub Desktop.
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
@Composable | |
fun VideoCallCompose() { | |
Scaffold( | |
content = { MyContent() } | |
) | |
} | |
@Composable | |
fun MyContent() { | |
val mUrl = "file:android_asset/call.html" | |
var isAudio by remember { | |
mutableStateOf(true) | |
} | |
var isVideo by remember { | |
mutableStateOf(true) | |
} | |
var webViewCompose: WebView? by remember { | |
mutableStateOf(null) | |
} | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
verticalArrangement = Arrangement.Top, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
AndroidView(factory = { | |
val layoutInflater: LayoutInflater = LayoutInflater.from(it) | |
val view: View = layoutInflater.inflate(R.layout.activity_call, null, false) | |
view | |
}, update = { view -> | |
val webView: WebView = view.findViewById(R.id.webView) | |
webViewCompose = webView | |
webView.loadUrl(mUrl) | |
WebRTCUtil.setupWebView(webView) | |
}) | |
Column(verticalArrangement = Arrangement.Bottom, modifier = Modifier.fillMaxHeight()) { | |
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { | |
Image( | |
modifier = Modifier.clickable { | |
isAudio = !isAudio | |
WebRTCUtil.callJavaScriptFunction( | |
webViewCompose!!, | |
"javascript:toggleAudio(\"$isAudio\")" | |
); | |
}, | |
painter = painterResource(id = if (isAudio) R.drawable.btn_mute_normal else R.drawable.btn_unmute_normal), | |
contentDescription = "audio" | |
) | |
Image( | |
modifier = Modifier.clickable { | |
WebRTCUtil.callJavaScriptFunction( | |
webViewCompose!!, | |
"javascript:disconnectCall()" | |
); | |
mainActivity.finish() | |
}, | |
painter = painterResource(id = R.drawable.btn_endcall_normal), | |
contentDescription = "end" | |
) | |
Image( | |
modifier = Modifier.clickable { | |
isVideo = !isVideo | |
WebRTCUtil.callJavaScriptFunction( | |
webViewCompose!!, | |
"javascript:toggleVideo(\"$isVideo\")" | |
); | |
}, | |
painter = painterResource(id = if (isVideo) R.drawable.btn_video_muted else R.drawable.btn_video_normal), | |
contentDescription = "video" | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment