UNPKG

@sendbird/calls-react-native

Version:

Sendbird Calls SDK for React Native: Empower React Native apps with seamless audio, video, and group calling. Build interactive communication easily.

153 lines (149 loc) 6.01 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable @typescript-eslint/no-unused-vars */ import { Platform } from 'react-native'; import { ControllableModuleType } from '../types'; export class Participant { /** @internal **/ static get(props, _binder, _internalEvents, _roomId) { if (!props) return null; const localParticipant = new Participant(props); return localParticipant._updateInternal(props); } constructor(props) { _defineProperty(this, "_props", void 0); this._props = props; } _updateInternal(props) { this._props = props; return this; } get participantId() { return this._props.participantId; } get user() { return this._props.user; } get state() { return this._props.state; } get enteredAt() { return this._props.enteredAt; } get exitedAt() { return this._props.exitedAt; } get duration() { return this._props.duration; } get isAudioEnabled() { return this._props.isAudioEnabled; } get isVideoEnabled() { return this._props.isVideoEnabled; } get updatedAt() { return this._props.updatedAt; } } export class LocalParticipant extends Participant { /** @internal **/ static get(props, binder, internalEvents, roomId) { if (!props) return null; return new LocalParticipant(props, binder, internalEvents, roomId); } constructor(props, binder, internalEvents, roomId) { super(props); _defineProperty(this, "_binder", void 0); _defineProperty(this, "_internalEvents", void 0); _defineProperty(this, "_roomId", void 0); /** * Mutes the audio of the local user. * Will trigger {@link RoomListener.onRemoteAudioSettingsChanged} method of remote participants. * If the remote user changes their audio settings, the local user will be notified via the same method. * * @since 1.0.0 */ _defineProperty(this, "muteMicrophone", () => { this._binder.nativeModule.muteMicrophone(ControllableModuleType.GROUP_CALL, this._roomId); // NOTE: native doesn't have onLocalAudioSettingsChanged event this._props.isAudioEnabled = false; this._internalEvents.emit('onPropertyUpdatedManually', this); }); /** * Unmutes the audio of the local user. * Will trigger {@link RoomListener.onRemoteAudioSettingsChanged} method of remote participants. * If the remote user changes their audio settings, the local user will be notified via the same method. * * @since 1.0.0 */ _defineProperty(this, "unmuteMicrophone", () => { this._binder.nativeModule.unmuteMicrophone(ControllableModuleType.GROUP_CALL, this._roomId); // NOTE: native doesn't have onLocalAudioSettingsChanged event this._props.isAudioEnabled = true; this._internalEvents.emit('onPropertyUpdatedManually', this); }); /** * Unmutes the audio of the local user. * Will trigger {@link RoomListener.onRemoteVideoSettingsChanged} method of remote participants. * If the remote user changes their video settings, the local user will be notified via the same method. * * @since 1.0.0 */ _defineProperty(this, "stopVideo", () => { this._binder.nativeModule.stopVideo(ControllableModuleType.GROUP_CALL, this._roomId); // NOTE: native doesn't have onLocalAudioSettingsChanged event this._props.isVideoEnabled = false; this._internalEvents.emit('onPropertyUpdatedManually', this); }); /** * Unmutes the audio of the local user. * Will trigger {@link RoomListener.onRemoteVideoSettingsChanged} method of remote participants. * If the remote user changes their video settings, the local user will be notified via the same method. * * @since 1.0.0 */ _defineProperty(this, "startVideo", () => { this._binder.nativeModule.startVideo(ControllableModuleType.GROUP_CALL, this._roomId); // NOTE: native doesn't have onLocalAudioSettingsChanged event this._props.isVideoEnabled = true; this._internalEvents.emit('onPropertyUpdatedManually', this); }); /** * Toggles the selection between the front and the back camera. * * on Android, In case of more than two cameras, the next camera will be selected. * If the last camera is already selected, the first one will be selected again. * * @since 1.0.0 */ _defineProperty(this, "switchCamera", () => { return this._binder.nativeModule.switchCamera(ControllableModuleType.GROUP_CALL, this._roomId); }); /** * Connects the device camera and Sendbird Calls SDK to stream video for local participant. * * @platform Android * @since 1.1.3 * */ _defineProperty(this, "android_resumeVideoCapturer", () => { if (Platform.OS !== 'android') return; return this._binder.nativeModule.resumeVideoCapturer(ControllableModuleType.GROUP_CALL, this._roomId); }); /** * Connects the device audio and Sendbird Calls SDK to stream audio. * * @platform Android * @since 1.1.5 * */ _defineProperty(this, "android_resumeAudioTrack", () => { if (Platform.OS !== 'android') return; return this._binder.nativeModule.resumeAudioTrack(ControllableModuleType.GROUP_CALL, this._roomId); }); this._binder = binder; this._internalEvents = internalEvents; this._roomId = roomId; } } //# sourceMappingURL=Participant.js.map