From 3a51edb22e8aee0c3fc2f40746248ac7be55f5b5 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 16 Dec 2024 11:16:35 +0530 Subject: [PATCH 1/2] MOB-1899: update quickstart page for android-core v2 --- docs/android-core/quickstart.mdx | 118 +++++++++++++++++-------------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/docs/android-core/quickstart.mdx b/docs/android-core/quickstart.mdx index 4cc59b055..3fbc18b0c 100644 --- a/docs/android-core/quickstart.mdx +++ b/docs/android-core/quickstart.mdx @@ -16,7 +16,7 @@ import { MavenLatestInstallation } from '@site/src/components/LatestInstallation This quickstart shows how to use Dyte's core SDKs to add live video and audio to your Android applications. -To get started quickly, you can use our sample code. You can clone and run a sample application from the Android Core samples, +To get started quickly, you can use our sample code. You can clone and run a sample application from the Android Core samples, available in both [Kotlin](https://github.com/dyte-io/android-samples/tree/main/samples/android-core-sample-kotlin) and [Java](https://github.com/dyte-io/android-samples/tree/main/samples/android-core-sample-java). ## Objective @@ -81,7 +81,7 @@ val dyteClient = DyteMeetingBuilder.build(activity) ```java -DyteMobileClient dyteClient = DyteMeetingBuilder.build(activity); +DyteMobileClient dyteClient = DyteMeetingBuilder.INSTANCE.build(activity); ``` @@ -89,7 +89,7 @@ DyteMobileClient dyteClient = DyteMeetingBuilder.build(activity); ## Step 3: Configure a Dyte meeting -Configure the following properties in the `DyteMeetingInfoV2` class. You must pass a valid participant `authToken` obtained from +Configure the following properties in the `DyteMeetingInfoV2` class. You must pass a valid participant `authToken` obtained from the [Add Participant](/api/?v=v2#/operations/add_participant) API. | Name | Description | @@ -97,19 +97,19 @@ the [Add Participant](/api/?v=v2#/operations/add_participant) API. | `authToken` | After you've created the meeting, add each participant to the meeting using the [Add Participant API](/api?v=v2#/operations/add_participant) The API response contains the `authToken`. | | `enableAudio` | Set whether to join the meeting with your Mic ON (`true`) or OFF (`false`). | | `enableVideo` | Set whether to join the meeting with your Camera ON (`true`) or OFF (`false`).| -| `baseUrl` | Base URL of the dyte's environment you have created the meeting on.| +| `baseDomain` | Base domain of the dyte's environment you have created the meeting on. Only required if using a white-labeled domain, defaults to "dyte.io" | ```kotlin val meetingInfo = - DyteMeetingInfoV2( - authToken = AUTH_TOKEN, - enableAudio = true, - enableVideo = true, - baseUrl = "dyte.io" - ) + DyteMeetingInfoV2( + authToken = AUTH_TOKEN, + enableAudio = true, + enableVideo = true, + baseDomain = "dyte.io" + ) ``` @@ -117,12 +117,13 @@ val meetingInfo = ```java -DyteMeetingInfoV2 meetingInfo = new DyteMeetingInfoV2( - MeetingConfig.AUTH_TOKEN, // auth_token - true, // enableAudio - true, // enableVideo - "dyte.io" // baseUrl - ); +DyteMeetingInfoV2 meetingInfo = + new DyteMeetingInfoV2( + MeetingConfig.AUTH_TOKEN, // authToken + true, // enableAudio + true, // enableVideo + "dyte.io" // baseUrl + ); ``` @@ -130,33 +131,38 @@ DyteMeetingInfoV2 meetingInfo = new DyteMeetingInfoV2( ## Step 4: Initialize the Dyte meeting -To initialize the meeting, call the `init()` method on the `dyteClient` object with the `meetingInfo` argument. This establishes +To initialize the meeting, call the `init()` method on the `dyteClient` object with the `meetingInfo` argument. This establishes a connection with the Dyte meeting server. ```kotlin -dyteClient.init(meetingInfo, { - // init complete - }, { - // init failed +dyteClient.init( + meetingInfo, + onInitCompleted = { + }, + onInitFailed = { } ) ``` - + ```java -dyteClient.init(meetingInfo, () -> { - // init complete - return null; - }, () -> { - // init failed - return null; - }); +dyteClient.init( + meetingInfo, + () -> { + // init complete + return null; + }, + () -> { + // init failed + return null; + } +); ``` @@ -174,10 +180,10 @@ To join the meeting room, call `joinRoom()` method on the `dyteClient` instance ```kotlin -dyteClient.joinRoom({ - // join complete - }, { - // join failed +dyteClient.joinRoom( + onSuccess = { + }, + onFailed = { } ) ``` @@ -187,13 +193,16 @@ dyteClient.joinRoom({ ```java -dyteClient.join(() -> { - // join complete - return null; - }, () -> { - // join failed - return null; - }); +dyteClient.joinRoom( + () -> { + // join complete + return null; + }, + () -> { + // join failed + return null; + } +); ``` @@ -209,24 +218,27 @@ To leave the meeting room, call `leaveRoom()` method on the `dyteClient` as show ```kotlin -dyteClient.leaveRoom({ - // leave completed -}, { - // leave failed -}) +dyteClient.leaveRoom( + onSuccess = { + }, + onFailed = { + } +) ``` ```java -dyteClient.leave(() -> { - // leave complete - return null; - }, () -> { - // leave failed - return null; - }); +dyteClient.leaveRoom( + () -> { + // leave complete + return null; + }, () -> { + // leave failed + return null; + } +); ``` @@ -238,4 +250,4 @@ dyteClient.leave(() -> { name="description" content="Explore Dyte's Android Core documentation, focusing on core functionalities for building rich video chat applications on Android." /> - \ No newline at end of file + From 9a2ea817850335ca233615ec5946623e1c58a472 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 18 Dec 2024 10:57:06 +0530 Subject: [PATCH 2/2] MOB-1901: update pre-call section for android-core v2 --- .../android-core/pre-call/1-media-preview.mdx | 142 +++++++++++++++--- .../pre-call/2-handling-permissions.mdx | 28 +++- docs/android-core/pre-call/3-meeting-meta.mdx | 16 +- docs/android-core/pre-call/4-waiting-room.mdx | 57 ++++++- 4 files changed, 214 insertions(+), 29 deletions(-) diff --git a/docs/android-core/pre-call/1-media-preview.mdx b/docs/android-core/pre-call/1-media-preview.mdx index 907ab2ae5..a083b1078 100644 --- a/docs/android-core/pre-call/1-media-preview.mdx +++ b/docs/android-core/pre-call/1-media-preview.mdx @@ -3,7 +3,7 @@ Before joining a meeting, users may want to preview and configure their media devices like camera, microphone, and audio output. This section provides developers with the tools to prepare the media environment before joining a Dyte meeting. -If you are using our UI Kits, this functionality can be handled by `DyteSetupFragment` or built with `DyteParticipantTileView` +If you are using our UI Kits, this functionality can be handled by `DyteSetupFragment` or built with `DyteParticipantTileView` and `DyteSettingsFragment` components. @@ -20,14 +20,32 @@ The same methods used for controlling media during a meeting are also applicable **1. Mute/Unmute microphone** + + + ```kotlin // Mute Audio -meeting.localUser.disableAudio() +meeting.localUser.disableAudio {} + +// Unmute Audio +meeting.localUser.enableAudio {} +``` + + + + + +```java +// Mute Audio +meeting.localUser.disableAudio(error -> null); // Unmute Audio -meeting.localUser.enableAudio() +meeting.localUser.enableAudio(error -> null); ``` + + + ```mermaid flowchart LR classDef basic fill:white; @@ -39,27 +57,65 @@ flowchart LR
-Anytime there is an update in the audio state of the local user, the Core SDK notifies the client through the `onAudioUpdate` callback +Anytime there is an update in the audio state of the local user, the Core SDK notifies the client through the `onAudioUpdate` callback from `DyteSelfEventsListener`. Here's how you can register the listener: + + + ```kotlin meeting.addSelfEventsListener(object : DyteSelfEventsListener { - override fun onAudioUpdate(audioEnabled: Boolean) { + override fun onAudioUpdate(isEnabled: Boolean) { // Show a visual preview of the audio to the user if enabled } }) ``` + + + + +```java +meeting.addSelfEventsListener(new DyteSelfEventsListener() { + @Override + public void onAudioUpdate(boolean isEnabled) { + // Show a visual preview of the audio to the user if enabled + } +}); +``` + + + + + **2. Enable/Disable camera** + + + ```kotlin // Disable Video -meeting.localUser.disableVideo() +meeting.localUser.disableVideo {} + +// Enable Video +meeting.localUser.enableVideo {} +``` + + + + + +```java +// Disable Video +meeting.localUser.disableVideo(error -> null); // Enable Video -meeting.localUser.enableVideo() +meeting.localUser.enableVideo(error -> null); ``` + + + ```mermaid flowchart LR classDef basic fill:white; @@ -70,32 +126,47 @@ flowchart LR ```
-Whenever there is an update in the video state of the local user, the Core SDK notifies the client through the `onVideoUpdate` callback +Whenever there is an update in the video state of the local user, the Core SDK notifies the client through the `onVideoUpdate` callback from `DyteSelfEventsListener`. Here's how you can register the listener: + + + ```kotlin meeting.addSelfEventsListener(object : DyteSelfEventsListener { - override fun onVideoUpdate(videoEnabled: Boolean) { + override fun onVideoUpdate(isEnabled: Boolean) { // Show local user's VideoView if video is enabled } }) ``` -### Changing Media Device - -Media devices represent the hardware for the camera, microphone, and speaker devices. To get the list of media devices currently -available, use the following methods: + -```kotlin -// Get all audio devices -val audioDevices = meeting.localUser.getAudioDevices() + -// Get all video devices -val videoDevices = meeting.localUser.getVideoDevices() +```java +meeting.addSelfEventsListener(new DyteSelfEventsListener() { + @Override + public void onVideoUpdate(boolean isEnabled) { + // Show local user's VideoView if video is enabled + } +}); ``` + + + + +### Changing Media Device + +Media devices represent the hardware for the camera, microphone, and speaker devices. To get the list of media devices currently +available, use the following methods: + To get the currently selected media device, use the following methods: + + + ```kotlin // Get current audio device being used val currentAudioDevice = meeting.localUser.getSelectedAudioDevice() @@ -104,10 +175,28 @@ val currentAudioDevice = meeting.localUser.getSelectedAudioDevice() val currentVideoDevice = meeting.localUser.getSelectedVideoDevice() ``` + + + + +```java +// Get current audio device being used +DyteAudioDevice currentAudioDevice = meeting.localUser.getSelectedAudioDevice(); + +// Get current video device being used +DyteVideoDevice currentVideoDevice = meeting.localUser.getSelectedVideoDevice(); +``` + + + + Use these methods to create a UI that allows users to configure their media devices. When the user selects a device, use the below methods to set the device. **Set device** + + + ```kotlin // Set audio device meeting.localUser.setAudioDevice(device) @@ -117,3 +206,20 @@ meeting.localUser.setAudioDevice(device) meeting.localUser.setVideoDevice(device) // eg. device = videoDevices[0] ``` + + + + + +```java +// Set audio device +meeting.localUser.setAudioDevice(device); +// eg. device = audioDevices.get(0) + +// Set video device +meeting.localUser.setVideoDevice(device); +// eg. device = videoDevices.get(0) +``` + + + diff --git a/docs/android-core/pre-call/2-handling-permissions.mdx b/docs/android-core/pre-call/2-handling-permissions.mdx index a96612fd9..c9e2b2602 100644 --- a/docs/android-core/pre-call/2-handling-permissions.mdx +++ b/docs/android-core/pre-call/2-handling-permissions.mdx @@ -1,12 +1,15 @@ # Handling Device Permissions -Before allowing users to interact with their camera and microphone, it's important to check if the necessary permissions are +Before allowing users to interact with their camera and microphone, it's important to check if the necessary permissions are granted on their Android device. Dyte's Android Core SDK provides easy-to-use APIs to check the status of these permissions. ### Checking Permissions Use the following APIs to check if the camera and microphone permissions are granted: + + + ```kotlin // Check if CAMERA permission is granted val cameraPermissionGranted = meeting.localUser.isCameraPermissionGranted @@ -15,17 +18,32 @@ val cameraPermissionGranted = meeting.localUser.isCameraPermissionGranted val micPermissionGranted = meeting.localUser.isMicrophonePermissionGranted ``` + + + + +```java +// Check if CAMERA permission is granted +boolean cameraPermissionGranted = meeting.localUser.isCameraPermissionGranted(); + +// Check if RECORD_AUDIO (microphone) permission is granted +boolean micPermissionGranted = meeting.localUser.isMicrophonePermissionGranted(); +``` + + + + Alternatively, you can also use Android's standard way to check if these permissions are granted: - `android.permission.CAMERA` - `android.permission.RECORD_AUDIO` -Refer to the [Android official documentation](https://developer.android.com/training/permissions/requesting#already-granted) +Refer to the [Android official documentation](https://developer.android.com/training/permissions/requesting#already-granted) for more information on checking permissions. -You can use the permission status to enable or disable camera and microphone buttons in the pre-call UI, or provide visual +You can use the permission status to enable or disable camera and microphone buttons in the pre-call UI, or provide visual feedback to indicate the availability of these media devices. ### Automatic Permission Request -When the Dyte SDK is initialised, it automatically checks for the required media permissions. If the permissions are not granted, -the SDK requests them on behalf of the developers. \ No newline at end of file +When the Dyte SDK is initialised, it automatically checks for the required media permissions. If the permissions are not granted, +the SDK requests them on behalf of the developers. diff --git a/docs/android-core/pre-call/3-meeting-meta.mdx b/docs/android-core/pre-call/3-meeting-meta.mdx index aac071725..db222ef76 100644 --- a/docs/android-core/pre-call/3-meeting-meta.mdx +++ b/docs/android-core/pre-call/3-meeting-meta.mdx @@ -4,8 +4,22 @@ You can allow the user to edit their name by using the `setDisplayName` method. + + + ```kotlin meeting.localUser.setDisplayName("New Name") ``` -**Note**: The name change will only be reflected to other participants if this method is called before joining the room. \ No newline at end of file + + + + +```java +meeting.localUser.setDisplayName("New Name"); +``` + + + + +**Note**: The name change will only be reflected to other participants if this method is called before joining the room. diff --git a/docs/android-core/pre-call/4-waiting-room.mdx b/docs/android-core/pre-call/4-waiting-room.mdx index a01217618..8b9c69c86 100644 --- a/docs/android-core/pre-call/4-waiting-room.mdx +++ b/docs/android-core/pre-call/4-waiting-room.mdx @@ -1,6 +1,6 @@ # Waiting Room -When you call `meeting.joinRoom()`, the user either enters the meeting room directly if allowed, or they are placed in the waiting room +When you call `meeting.joinRoom()`, the user either enters the meeting room directly if allowed, or they are placed in the waiting room if they are a waitlisted participant. The diagram illustrates the possible room states the local user can be in. @@ -17,25 +17,49 @@ stateDiagram-v2 ### Meeting Room Joined -If user joins the room successfully, you receive the `onMeetingRoomJoinCompleted` callback in `DyteMeetingRoomEventsListener`. +If user joins the room successfully, you receive the `onMeetingRoomJoinCompleted` callback in `DyteMeetingRoomEventsListener`. You can listen for this callback as follows: + + + ```kotlin meeting.addMeetingRoomEventsListener(object : DyteMeetingRoomEventsListener { - override fun onMeetingRoomJoinCompleted() { + override fun onMeetingRoomJoinCompleted(meeting: DyteMobileClient) { // Local user is in the meeting } }) ``` + + + + + +```java +meeting.addMeetingRoomEventsListener(new DyteMeetingRoomEventsListener() { + @Override + public void onMeetingRoomJoinCompleted(DyteMobileClient meeting) { + // Local user is in the meeting + } +}) +``` + + + + + ### Waitlisted Participant -If the user is waitlisted, the `onWaitListStatusUpdate` callback in `DyteSelfEventsListener` notifies you of any changes in the +If the user is waitlisted, the `onWaitListStatusUpdate` callback in `DyteSelfEventsListener` notifies you of any changes in the user's waitlist status. You can check the `waitListStatus` to determine their status: - `WAITING`: Local user is in the waiting room. - `REJECTED`: Local user's join room request is rejected by the host. + + + ```kotlin meeting.addSelfEventsListener(object : DyteSelfEventsListener { override fun onWaitListStatusUpdate(waitListStatus: WaitListStatus) { @@ -52,4 +76,27 @@ meeting.addSelfEventsListener(object : DyteSelfEventsListener { }) ``` -Host can use [these methods to accept/reject participants](/android-core/participants#waiting-room-methods). \ No newline at end of file + + + + +```java +meeting.addSelfEventsListener(new DyteSelfEventsListener() { + @Override + public void onWaitListStatusUpdate(waitListStatus: WaitListStatus) { + switch (waitListStatus) { + case WAITING: + // Local user is in the waiting room + break; + case REJECTED: + // Local user's join room request was rejected by the host + break; + } + } +}); +``` + + + + +Host can use [these methods to accept/reject participants](/android-core/participants#waiting-room-methods).