Skip to content

Commit

Permalink
Merge pull request #407 from harshs-dyte/hs/mobile-v2
Browse files Browse the repository at this point in the history
docs: start updating android-core docs for v2
  • Loading branch information
harshs-dyte authored Dec 18, 2024
2 parents 7455df6 + 9a2ea81 commit 798f54e
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 82 deletions.
142 changes: 124 additions & 18 deletions docs/android-core/pre-call/1-media-preview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.


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.
57 changes: 52 additions & 5 deletions docs/android-core/pre-call/4-waiting-room.mdx
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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:

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

```kotlin
meeting.addMeetingRoomEventsListener(object : DyteMeetingRoomEventsListener {
override fun onMeetingRoomJoinCompleted() {
override fun onMeetingRoomJoinCompleted(meeting: DyteMobileClient) {
// Local user is in the meeting
}
})
```


</TabItem>

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

```java
meeting.addMeetingRoomEventsListener(new DyteMeetingRoomEventsListener() {
@Override
public void onMeetingRoomJoinCompleted(DyteMobileClient meeting) {
// Local user is in the meeting
}
})
```


</TabItem>
</Tabs>

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

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

```kotlin
meeting.addSelfEventsListener(object : DyteSelfEventsListener {
override fun onWaitListStatusUpdate(waitListStatus: WaitListStatus) {
Expand All @@ -52,4 +76,27 @@ meeting.addSelfEventsListener(object : DyteSelfEventsListener {
})
```

Host can use [these methods to accept/reject participants](/android-core/participants#waiting-room-methods).
</TabItem>

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

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

</TabItem>
</Tabs>

Host can use [these methods to accept/reject participants](/android-core/participants#waiting-room-methods).
Loading

0 comments on commit 798f54e

Please sign in to comment.