From 6bf214d946ec6620fc9b68f2c123ff26a13b9de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Po=C5=BCyczka?= Date: Wed, 6 Sep 2023 09:20:02 +0200 Subject: [PATCH] Add setAllParticipantsVolume for RN + Android --- .../services/audio/RNRemoteAudioModule.kt | 15 +++- docs/classes/internal.RemoteAudio.md | 22 +++++ .../ConferenceScreenBottomSheet.tsx | 84 ++++++++++++++----- example/src/utils/audio.tester.ts | 12 ++- src/services/audio/RemoteAudio.ts | 12 +++ 5 files changed, 119 insertions(+), 26 deletions(-) diff --git a/android/src/main/java/io/dolby/sdk/comms/reactnative/services/audio/RNRemoteAudioModule.kt b/android/src/main/java/io/dolby/sdk/comms/reactnative/services/audio/RNRemoteAudioModule.kt index 4023fbd9..74420144 100644 --- a/android/src/main/java/io/dolby/sdk/comms/reactnative/services/audio/RNRemoteAudioModule.kt +++ b/android/src/main/java/io/dolby/sdk/comms/reactnative/services/audio/RNRemoteAudioModule.kt @@ -1,5 +1,4 @@ package io.dolby.sdk.comms.reactnative.services.audio - import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactContextBaseJavaModule import com.facebook.react.bridge.ReactMethod @@ -85,6 +84,20 @@ class RNRemoteAudioModule( .forward(promise, ignoreReturnType = true) } + /** + * Sets the conference volume for the local participant. + * The method sets the volume of all remote participants to a preferred value between 0 and 1. + * Providing an unsupported volume results in constraining volume to a either 0 or 1. + * This method is supported in SDK 3.11 and later. + * + * @param volume + */ + @ReactMethod + fun setAllParticipantsVolume(volume: Float, promise: ReactPromise) { + Promises.promise(audioService.remote.setOutputVolume(volume)) + .forward(promise, ignoreReturnType = true) + } + /** * Gets [Participant] based on a React Native participant model. Throws * [IllegalArgumentException] if participant id is invalid. diff --git a/docs/classes/internal.RemoteAudio.md b/docs/classes/internal.RemoteAudio.md index 18866423..6ffc22dc 100644 --- a/docs/classes/internal.RemoteAudio.md +++ b/docs/classes/internal.RemoteAudio.md @@ -17,6 +17,7 @@ This model is supported only in SDK 3.7 and later. - [start](internal.RemoteAudio.md#start) - [stop](internal.RemoteAudio.md#stop) - [setVolume](internal.RemoteAudio.md#setvolume) +- [setAllParticipantsVolume](internal.RemoteAudio.md#setallparticipantsvolume) ## Constructors @@ -86,3 +87,24 @@ This method is supported in SDK 3.11 and later. #### Returns `Promise`<`void`\> + +___ + +### setAllParticipantsVolume + +▸ **setAllParticipantsVolume**(`volume`): `Promise`<`void`\> + +Sets the conference volume for the local participant. The method sets the volume of all remote participants to a preferred value between 0 and 1. +Providing an unsupported volume results in constraining volume to a either 0 or 1. + +This method is supported in SDK 3.11 and later. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `volume` | `number` | The preferred volume level between 0 (no audio) and 1 (full volume). | + +#### Returns + +`Promise`<`void`\> diff --git a/example/src/screens/ConferenceScreen/ConferenceScreenBottomSheet.tsx b/example/src/screens/ConferenceScreen/ConferenceScreenBottomSheet.tsx index b0cf698b..670ffe9b 100644 --- a/example/src/screens/ConferenceScreen/ConferenceScreenBottomSheet.tsx +++ b/example/src/screens/ConferenceScreen/ConferenceScreenBottomSheet.tsx @@ -19,6 +19,7 @@ import { setComfortNoiseLevel, startLocalAudio, stopLocalAudio, + setAllParticipantsVolume, } from '@utils/audio.tester'; import { sendCommandMessage } from '@utils/command.tester'; import { @@ -70,12 +71,12 @@ import { import { Conference, VoiceFont } from '@dolbyio/comms-sdk-react-native/models'; import styles from './ConferenceScreen.style'; -import { - AudioProcessingOptions, - VideoForwardingStrategy, - AudioCaptureMode, - ComfortNoiseLevel, - NoiseReductionLevel +import { + AudioProcessingOptions, + VideoForwardingStrategy, + AudioCaptureMode, + ComfortNoiseLevel, + NoiseReductionLevel } from '@dolbyio/comms-sdk-react-native/models'; import { startLocalVideo, stopLocalVideo } from '@utils/video.tester'; @@ -160,8 +161,8 @@ const ConferenceScreenBottomSheet = () => { }, ]; - const voiceFontAction: (voiceFont: VoiceFont) => () => void = (voiceFont) => { - return () => setAudioCaptureMode({ mode: AudioCaptureMode.Standard, noiseReduction: NoiseReductionLevel.Low, voiceFont: voiceFont }) + const voiceFontAction: (voiceFont: VoiceFont) => () => void = (voiceFont) => { + return () => setAudioCaptureMode({ mode: AudioCaptureMode.Standard, noiseReduction: NoiseReductionLevel.Low, voiceFont: voiceFont }) }; const voiceFontOptions: Array<{ text: string; @@ -345,17 +346,54 @@ const ConferenceScreenBottomSheet = () => {