import { NativeModules, Platform } from 'react-native'; import Logger from '../../utils/Logger'; import type { ComfortNoiseLevel } from '../audio/models'; const { CommsAPIMediaDeviceServiceModule } = NativeModules; /** * The MediaDeviceService allows an application to manage media devices that are used during a conference. */ export class MediaDeviceService { /** @internal */ _nativeModule = CommsAPIMediaDeviceServiceModule; /** * **Note**: This method is deprecated in SDK 3.7 and replaced with the [getComfortNoiseLevel](doc:rn-client-sdk-references-localaudio#getcomfortnoiselevel) method available in the [LocalAudio](doc:rn-client-sdk-references-localaudio) model * * Retrieves the comfort noise level setting for output devices in Dolby Voice conferences. */ public async getComfortNoiseLevel(): Promise { return this._nativeModule.getComfortNoiseLevel(); } /** * Checks whether an application uses the front-facing (true) or back-facing camera (false). */ public async isFrontCamera(): Promise { return this._nativeModule.isFrontCamera(); } /** * **Note**: This method is deprecated in SDK 3.7 and replaced with the [setComfortNoiseLevel](doc:rn-client-sdk-references-localaudio#setcomfortnoiselevel) method available in the [LocalAudio](doc:rn-client-sdk-references-localaudio) model. * * Configures the comfort noise level for output devices in Dolby Voice conferences. * * @param noiseLevel The selected comfort noise level. */ public async setComfortNoiseLevel( noiseLevel: ComfortNoiseLevel ): Promise { return this._nativeModule.setComfortNoiseLevel(noiseLevel); } /** * Switches the current camera to another available camera that is connected to a device. * @returns {Promise { return this._nativeModule.switchCamera(); } /** * Switches the current speaker to another available speaker that is connected to a device. */ public async switchSpeaker(): Promise { if (Platform.OS === 'android') { Logger.warning('Switching speaker is not available on Android devices'); return Promise.reject( 'Switching speaker is not available on Android devices' ); } return this._nativeModule.switchSpeaker(); } } export default new MediaDeviceService();