mediasfu-reactnative-expo
Version:
mediasfu-reactnative-expo – Expo-managed React Native WebRTC SDK for video conferencing, webinars, live streaming, broadcast, screen sharing, whiteboard, chat, recording, live subtitles, translation, and AI agent rooms on iOS, Android, and web. Prebuilt r
54 lines • 3 kB
JavaScript
import { switchUserVideo as sharedSwitchUserVideo } from 'mediasfu-shared';
/**
* Switches the user's video input device based on the provided options.
*
* @param {SwitchUserVideoOptions} options - The options for switching the user's video.
* @param {string} options.videoPreference - The preferred video input device ID.
* @param {boolean} options.checkoff - Flag indicating whether to turn off the video.
* @param {Object} options.parameters - Additional parameters required for switching the video.
* @param {boolean} options.parameters.audioOnlyRoom - Indicates if the room is audio-only.
* @param {number} options.parameters.frameRate - The desired frame rate for the video.
* @param {Object} options.parameters.vidCons - Video constraints such as width and height.
* @param {string} options.parameters.prevVideoInputDevice - The previous video input device ID.
* @param {Function} options.parameters.showAlert - Function to show alerts to the user.
* @param {Object} options.parameters.mediaDevices - Media devices object to access user media.
* @param {boolean} options.parameters.hasCameraPermission - Indicates if the user has camera permission.
* @param {Function} options.parameters.updateVideoSwitching - Function to update video switching state.
* @param {Function} options.parameters.updateUserDefaultVideoInputDevice - Function to update the default video input device.
* @param {Function} options.parameters.requestPermissionCamera - Function to request camera permission.
* @param {Function} options.parameters.streamSuccessVideo - Function to handle successful video stream.
* @param {Function} options.parameters.sleep - Function to pause execution for a specified duration.
* @param {Function} options.parameters.checkMediaPermission - Function to check media permissions.
*
* @returns {Promise<void>} A promise that resolves when the video input device has been successfully switched.
*
* @throws Will throw an error if the audio input device cannot be accessed or if there is an unexpected error.
*
* @example
* ```typescript
* await switchUserVideo({
* videoPreference: 'video-device-id',
* checkoff: false,
* parameters: {
* audioOnlyRoom: false,
* frameRate: 30,
* vidCons: { width: 640, height: 480 },
* prevVideoInputDevice: 'prev-video-device-id',
* showAlert: showAlertFunction,
* mediaDevices: navigator.mediaDevices,
* hasCameraPermission: true,
* updateVideoSwitching: updateVideoSwitchingFunction,
* updateUserDefaultVideoInputDevice: updateUserDefaultVideoInputDeviceFunction,
* requestPermissionCamera: requestPermissionCameraFunction,
* streamSuccessVideo: streamSuccessVideoFunction,
* sleep: sleepFunction,
* checkMediaPermission: true,
* getUpdatedAllParams: getUpdatedAllParamsFunction,
* },
* });
* ```
*/
export const switchUserVideo = async (options) => {
await sharedSwitchUserVideo(options);
};
//# sourceMappingURL=switchUserVideo.js.map