Skip to content

Commit

Permalink
MOB-1901: update pre-call section for android-core v2
Browse files Browse the repository at this point in the history
  • Loading branch information
harshs-dyte committed Dec 18, 2024
1 parent 3a51edb commit 48f4ac1
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 30 deletions.
144 changes: 125 additions & 19 deletions docs/android-core/pre-call/1-media-preview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span className="tag-orange">boolean</span> value indicating if the audio currently enabled.
- `meeting.localUser.videoEnabled`: A <span className="tag-orange">boolean</span> value indicating if the video currently enabled.
- `meeting.localUser.isEnabled`: A <span className="tag-orange">boolean</span> value indicating if the video currently enabled.

## Methods

Expand All @@ -20,14 +20,32 @@ The same methods used for controlling media during a meeting are also applicable

**1. Mute/Unmute microphone**

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```kotlin
// Mute Audio
meeting.localUser.disableAudio()
meeting.localUser.disableAudio {}

// Unmute Audio
meeting.localUser.enableAudio {}
```

</TabItem>

<TabItem value="java" label="Java" default>

```java
// Mute Audio
meeting.localUser.disableAudio(error -> null);

// Unmute Audio
meeting.localUser.enableAudio()
meeting.localUser.enableAudio(error -> null);
```

</TabItem>
</Tabs>

```mermaid
flowchart LR
classDef basic fill:white;
Expand All @@ -39,27 +57,65 @@ flowchart LR

<br />

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:

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```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
}
})
```

</TabItem>

<TabItem value="java" label="Java" default>

```java
meeting.addSelfEventsListener(new DyteSelfEventsListener() {
@Override
public void onAudioUpdate(boolean isEnabled) {
// Show a visual preview of the audio to the user if enabled
}
});
```

</TabItem>
</Tabs>


**2. Enable/Disable camera**

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```kotlin
// Disable Video
meeting.localUser.disableVideo()
meeting.localUser.disableVideo {}

// Enable Video
meeting.localUser.enableVideo {}
```

</TabItem>

<TabItem value="java" label="Java" default>

```java
// Disable Video
meeting.localUser.disableVideo(error -> null);

// Enable Video
meeting.localUser.enableVideo()
meeting.localUser.enableVideo(error -> null);
```

</TabItem>
</Tabs>

```mermaid
flowchart LR
classDef basic fill:white;
Expand All @@ -70,32 +126,47 @@ flowchart LR
```
<br />

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:

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```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:
</TabItem>

```kotlin
// Get all audio devices
val audioDevices = meeting.localUser.getAudioDevices()
<TabItem value="java" label="Java" default>

// 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
}
});
```

</TabItem>
</Tabs>


### 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:

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```kotlin
// Get current audio device being used
val currentAudioDevice = meeting.localUser.getSelectedAudioDevice()
Expand All @@ -104,10 +175,28 @@ val currentAudioDevice = meeting.localUser.getSelectedAudioDevice()
val currentVideoDevice = meeting.localUser.getSelectedVideoDevice()
```

</TabItem>

<TabItem value="java" label="Java" default>

```java
// Get current audio device being used
DyteAudioDevice currentAudioDevice = meeting.localUser.getSelectedAudioDevice();

// Get current video device being used
DyteVideoDevice currentVideoDevice = meeting.localUser.getSelectedVideoDevice();
```

</TabItem>
</Tabs>

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**

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```kotlin
// Set audio device
meeting.localUser.setAudioDevice(device)
Expand All @@ -117,3 +206,20 @@ meeting.localUser.setAudioDevice(device)
meeting.localUser.setVideoDevice(device)
// eg. device = videoDevices[0]
```

</TabItem>

<TabItem value="java" label="Java" default>

```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)
```

</TabItem>
</Tabs>
28 changes: 23 additions & 5 deletions docs/android-core/pre-call/2-handling-permissions.mdx
Original file line number Diff line number Diff line change
@@ -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:

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```kotlin
// Check if CAMERA permission is granted
val cameraPermissionGranted = meeting.localUser.isCameraPermissionGranted
Expand All @@ -15,17 +18,32 @@ val cameraPermissionGranted = meeting.localUser.isCameraPermissionGranted
val micPermissionGranted = meeting.localUser.isMicrophonePermissionGranted
```

</TabItem>

<TabItem value="java" label="Java" default>

```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();
```

</TabItem>
</Tabs>

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.
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.
16 changes: 15 additions & 1 deletion docs/android-core/pre-call/3-meeting-meta.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@

You can allow the user to edit their name by using the `setDisplayName` method.

<Tabs groupId="android-core-media-preview">
<TabItem value="kotlin" label="Kotlin" default>

```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.
</TabItem>

<TabItem value="java" label="Java" default>

```java
meeting.localUser.setDisplayName("New Name");
```

</TabItem>
</Tabs>

**Note**: The name change will only be reflected to other participants if this method is called before joining the room.
Loading

0 comments on commit 48f4ac1

Please sign in to comment.