Skip to content

Commit

Permalink
Improve sound docs (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar authored Sep 24, 2024
1 parent 7f45223 commit c1a546e
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions docusaurus/docs/Android/06-advanced/01-ringing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ call.leave()

## Ringing sounds

The SDK plays sounds for incoming and outgoing calls. The SDK bundles two sounds for this
purpose.
The SDK plays sounds for incoming and outgoing calls. It bundles two sounds for this purpose.

### Customizing the ringing sounds

Expand All @@ -174,26 +173,36 @@ You can place your own `call_incoming_sound.mp3` and `call_outgoing_sound.mp3` f
You can customize the sounds by creating a `RingingConfig`.

:::note
Currently the SDK accepts a `Sounds` object in the builder, so once you have a `RingingConfig`, you can
Currently, the SDK accepts a `Sounds` object in the builder, so once you have a `RingingConfig`, you can
create a `Sounds` object via `ringingConfig.toSounds()` and pass it to the `StreamVideoBuilder`.
:::

The `RingingConfig` interface defines two properties:

- `incomingCallSoundUri`: The URI for the incoming call sound.
- `outgoingCallSoundUri`: The URI for the outgoing call sound.

You can implement this interface and provide your own values for the properties (e.g. a user chosen
URI). After that, create a `Sounds` object (e.g. `ringingConfig.toSounds()` or `Sounds(ringingConfig)`) and pass it to the SDK builder.
If one of the `Uri`s is null the SDK will simply not play that sound and log an error.

:::caution
The `Sounds` class is deprecated and will entirely be replaced by `RingingConfig` in the future.
The current `Sounds` constructor which accepts two integers will always return an `emptyRingingConfig()`
The current `Sounds` constructor that accepts two integers will always return an `emptyRingingConfig()`
with muted sounds.
:::

The `RingingConfig` interface defines two properties:
`RingingConfig` can also be created via several factory methods:

- `incomingCallSoundUri`: The URI for the incoming call sound.
- `outgoingCallSoundUri`: The URI for the outgoing call sound.
- `defaultResourcesRingingConfig` - This method returns a `RingingConfig` that uses the SDK's
default sounds for both incoming and outgoing calls
- `resRingingConfig` - This method returns a `RingingConfig` that uses a resource identifier for both incoming and outgoing calls.
- `uriRingingConfig(Uri, Uri)` - Returns a `RingingConfig` that is configured with two `Uri` objects for the corresponding sounds.
- `emptyRingingConfig` - The SDK will not play any sounds for incoming and outgoing calls.

You can implement this interface and provide your own values for the properties (e.g. a user chosen
URI). After that, create a `Sounds` object using the `RingingConfig` instance (e.g. `Sounds(ringingConfig)`) and pass the `Sounds` object to the SDK builder.
If one of the `Uri`s is null the SDK will simply not play that sound and log this fact instead.
#### Customization examples

For example, to create a `RingingConfig` that only includes an incoming sound you can extend it as shown below, setting `outgoingCallSoundUri` is `null`:
For example, to create a sound config that only includes an incoming sound and no outgoing sound, you can extend `RingingConfig` as shown below, setting `outgoingCallSoundUri` to `null`:

```kotlin
class IncomingOnlyRingingConfig : RingingConfig {
Expand All @@ -204,18 +213,8 @@ class IncomingOnlyRingingConfig : RingingConfig {
}
```

`RingingConfig` can also be created via several factory methods:

- `defaultResourcesRingingConfig` - This method returns a `RingingConfig` that uses the SDK's
default sounds for both incoming and outgoing calls
- `resRingingConfig` - This method returns a `RingingConfig` that uses a resource identifier for both incoming and outgoing calls.
- `uriRingingConfig(Uri, Uri)` - Returns a `RingingConfig` that is configured with two `Uri` objects for the corresponding sounds.
- `emptyRingingConfig` - The SDK will not play any sounds for incoming and outgoing calls.

For further customization its best to provide your own `RingingConfig` implementation.
Such use cases may include a user setting to choose a sound or a custom sound that is not bundled.
Another use case may include a user-chosen sound or a custom sound that is not bundled:

For example:
```kotlin
data class UserRingingConfig(
val incomingCallSoundUri: Uri,
Expand Down

0 comments on commit c1a546e

Please sign in to comment.