|
| 1 | +/* |
| 2 | + * Copyright 2023 Stream.IO, Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.getstream.whatsappclone.video |
| 18 | + |
| 19 | +import androidx.compose.runtime.Composable |
| 20 | +import androidx.compose.runtime.getValue |
| 21 | +import androidx.compose.runtime.mutableStateOf |
| 22 | +import androidx.compose.runtime.remember |
| 23 | +import androidx.compose.runtime.setValue |
| 24 | +import androidx.compose.ui.platform.LocalContext |
| 25 | +import io.getstream.video.android.core.Call |
| 26 | + |
| 27 | +@Composable |
| 28 | +fun WhatsAppVideoCall(id: String) { |
| 29 | + val context = LocalContext.current |
| 30 | + |
| 31 | + var call: Call? by remember { mutableStateOf(null) } |
| 32 | + |
| 33 | +// LaunchedEffect(key1 = Unit) { |
| 34 | +// val userToken = |
| 35 | +// "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiQmVuX1NreXdhbGtlciIsImlzcyI6InByb250byIsInN1YiI6InVzZXIvQmVuX1NreXdhbGtlciIsImlhdCI6MTY5Njk4NDE3MywiZXhwIjoxNjk3NTg4OTc4fQ.Cdq_sw1ZA_PiGNXmOIZdxZjmlBKK8DuW8Oy_YjKloZw" |
| 36 | +// val userId = "Ben_Skywalker" |
| 37 | +// val callId = "dE8AsD5Qxqrt" |
| 38 | +// |
| 39 | +// // step1 - create a user. |
| 40 | +// val user = User( |
| 41 | +// id = userId, // any string |
| 42 | +// name = "Tutorial", // name and image are used in the UI |
| 43 | +// role = "admin", |
| 44 | +// ) |
| 45 | +// |
| 46 | +// // step2 - initialize StreamVideo. For a production app we recommend adding the client to your Application class or di module. |
| 47 | +// val client = StreamVideoBuilder( |
| 48 | +// context = context, |
| 49 | +// apiKey = stringResource(id = R.string.), |
| 50 | +// geo = GEO.GlobalEdgeNetwork, |
| 51 | +// user = user, |
| 52 | +// token = userToken, |
| 53 | +// ensureSingleInstance = false, |
| 54 | +// ).build() |
| 55 | +// |
| 56 | +// // step3 - join a call, which type is `default` and id is `123`. |
| 57 | +// call = client.call("livestream", callId) |
| 58 | +// |
| 59 | +// // join the cal |
| 60 | +// val result = call?.join() |
| 61 | +// result?.onError { |
| 62 | +// Toast.makeText(context, "uh oh $it", Toast.LENGTH_SHORT).show() |
| 63 | +// } |
| 64 | +// } |
| 65 | +} |
0 commit comments