From 48f4ac10d38cf004091b5eff04ab18dbda9eecdf Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 18 Dec 2024 10:57:06 +0530 Subject: [PATCH] MOB-1901: update pre-call section for android-core v2 --- .../android-core/pre-call/1-media-preview.mdx | 144 +++++++++++++++--- .../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, 215 insertions(+), 30 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..c84d74955 100644 --- a/docs/android-core/pre-call/1-media-preview.mdx +++ b/docs/android-core/pre-call/1-media-preview.mdx @@ -3,14 +3,14 @@ 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. ## Properties - `meeting.localUser.audioEnabled`: A boolean value indicating if the audio currently enabled. -- `meeting.localUser.videoEnabled`: A boolean value indicating if the video currently enabled. +- `meeting.localUser.isEnabled`: A boolean value indicating if the video currently enabled. ## Methods @@ -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).