switchVideo

suspend fun switchVideo(options: SwitchVideoOptions)

Switches the user's video device based on the provided video preference.

This function performs the following tasks:

  • Checks if the room is audio-only and shows an alert if camera usage is restricted.

  • Validates recording states to determine if video can be switched.

  • Checks if camera access is allowed and prompts the user accordingly.

  • Updates the default and previous video input devices.

  • Calls the switchUserVideo function to perform the actual video device switching.

Parameters:

  • options (SwitchVideoOptions): Contains the videoPreference and parameters required for switching video.

Example:

val switchVideoOptions = SwitchVideoOptions(
videoPreference = "newVideoDeviceID",
parameters = object : SwitchVideoParameters {
override val recordStarted: Boolean = true
override val recordResumed: Boolean = false
override val recordStopped: Boolean = false
override val recordPaused: Boolean = false
override val recordingMediaOptions: String = "video"
override val videoAlreadyOn: Boolean = true
override val userDefaultVideoInputDevice: String = "currentVideoDeviceID"
override val defVideoID: String = "defaultVideoDeviceID"
override val allowed: Boolean = true
override val updateDefVideoID: (String) -> Unit = { deviceId -> setDefVideoID(deviceId) }
override val updatePrevVideoInputDevice: (String) -> Unit = { deviceId -> setPrevVideoDevice(deviceId) }
override val updateUserDefaultVideoInputDevice: (String) -> Unit = { deviceId -> setUserDefaultVideo(deviceId) }
override val updateIsMediaSettingsModalVisible: (Boolean) -> Unit = { isVisible -> setMediaSettingsModal(isVisible) }
override val showAlert: ShowAlert? = { message, type, duration ->
showAlert(message, type, duration)
}
override val switchUserVideo: SwitchUserVideoType = switchUserVideoFunction
// Other properties...
}
)

switchVideo(switchVideoOptions)