import { Platform } from 'react-native'; import { HMSManagerModule } from '@100mslive/react-native-hms'; import { ReactNativeVideoPlugin } from './modules/ReactNativeVideoPluginModule'; const _nativeModule = Platform.OS === 'android' ? ReactNativeVideoPlugin.nativeModule : HMSManagerModule; export class HMSVideoPlugin { protected type: string; constructor(pluginType: string) { this.type = pluginType; } protected get nativeModule() { return _nativeModule; } /** * Enables video plugin. * @returns {Promise} A promise that resolves to true when video plugin is enabled, otherwise, rejected promise is returned */ async enable(): Promise { const data = { id: '12345', type: this.type }; if (__DEV__) console.log('#Function HMSVirtualBackgroundPlugin#enable', data); try { return await this.nativeModule.enableVideoPlugin(data); } catch (e) { if (__DEV__) console.warn( '#Error in #Function HMSVirtualBackgroundPlugin#enable ', e ); return Promise.reject(e); } } /** * Disable video plugin. * @returns {Promise} A promise that resolves to true when video plugin is disabled, otherwise, rejected promise is returned */ async disable(): Promise { const data = { id: '12345', type: this.type }; if (__DEV__) console.log('#Function HMSVirtualBackgroundPlugin#disable', data); try { return await this.nativeModule.disableVideoPlugin(data); } catch (e) { if (__DEV__) console.warn( '#Error in #Function HMSVirtualBackgroundPlugin#disable ', e ); return Promise.reject(e); } } }