Skip to main content

Choose Devices, Backgrounds, and Translation by SDK

Help people choose a microphone or camera, change cameras, apply a virtual background, and use translation without rebuilding the room's media pipeline. Start with the supplied media settings. Move to low-level functions only when your custom UI already owns the complete current room parameters.

Before you add controls

  • Enumerate devices only after the platform permits it. Device labels may be blank before permission is granted.
  • A selected device is not proof of a published track. Confirm the producer and remote playback separately.
  • Stop the superseded input track after a successful switch.
  • Keep a no-effect fallback. Background processing can be unavailable or too expensive on an older device.
  • Show translation only when the room enables it. Language availability, accuracy, captions, translated audio, and retention are separate promises.

ReactJS 4.3.0

Use MediaSettingsModal for the supplied picker. A custom room can call switchUserAudio and switchUserVideo with the complete live options. BackgroundModal and launchBackground provide the supplied virtual- background path.

import {switchUserAudio, switchUserVideo} from 'mediasfu-reactjs';

export type MicrophoneSelection = Parameters<typeof switchUserAudio>[0];
export type CameraSelection = Parameters<typeof switchUserVideo>[0];

export const chooseMicrophone = (options: MicrophoneSelection) =>
switchUserAudio(options);
export const chooseCamera = (options: CameraSelection) =>
switchUserVideo(options);

The supplied modern room can present subtitles and translation configured for the room. ReactJS 4.2.9 does not publish a stable standalone translation service from the package root, so keep custom translation inside the supplied room rather than importing an internal module.

Angular 2.3.1

Use MediaSettingsModal, SwitchUserAudio, and SwitchUserVideo for input selection. Use BackgroundModal and LaunchBackground for the supplied background experience. TranslationSettingsModal, LiveSubtitleService, TranslationConsumerSwitch, and TranslationReceiveMethods are the public translation surfaces for an enabled room.

The following service is a complete, typed boundary for a microphone picker. Pass the selected device ID and the current room's parameter object; the SDK keeps permission checks, stream replacement, and failure alerts in one flow:

import {Injectable} from '@angular/core';
import {
SwitchUserAudio,
type SwitchUserAudioOptions,
} from 'mediasfu-angular';

@Injectable({providedIn: 'root'})
export class MicrophonePicker {
constructor(private readonly switchAudio: SwitchUserAudio) {}

select(
deviceId: string,
room: SwitchUserAudioOptions['parameters'],
): Promise<void> {
return this.switchAudio.switchUserAudio({
audioPreference: deviceId,
parameters: room,
});
}
}

Keep these services connected to the active room's parameter object. A service class name is not permission to construct partial transports or socket state.

Vue 1.1.1

Use the supplied room's media settings for device selection. The package root does not expose the same standalone device-switch contract as ReactJS. BackgroundModal and useBackgroundModal provide the Vue background UI. liveSubtitleService, createLiveSubtitleService, and translation receive services support presentation after the room enables translation.

If the application enumerates devices itself, keep that selection in the Vue application and pass the resulting current-room state through the supported room boundary.

React Native 2.4.0

Use MediaSettingsModal for supplied controls. switchVideoAlt flips the front/back camera; switchUserVideo and switchUserVideoAlt support the selected-camera flow. The package root does not publish microphone-device selection, and the operating system owns Bluetooth, wired, and speaker routes.

import {switchVideoAlt} from 'mediasfu-reactnative';

export type CameraFlip = Parameters<typeof switchVideoAlt>[0];
export const flipCamera = (options: CameraFlip) => switchVideoAlt(options);

Use BackgroundModal for supplied effects and TranslationSettingsModal for rooms configured for translation. Test camera switching, effect performance, interruptions, and translated playback on physical Android and iOS devices.

Expo 2.5.0

Expo exposes MediaSettingsModal, switchVideoAlt, switchUserVideo, and switchUserVideoAlt. Microphone-device selection and system audio routes are not package-root controls. Use BackgroundModal and TranslationSettingsModal through the active room.

Test Android, iOS, and web independently. A camera or background that works in Expo web does not prove the native path, and a native permission grant does not prove remote media or translated audio playback.

Flutter 2.3.0

Flutter exports getMediaDevicesList, switchAudio, switchVideo, and MediaSettingsModal. The supplied media settings also expose virtual- background controls where the release target supports processing.

import 'package:mediasfu_sdk/mediasfu_sdk.dart';

Future<void> chooseMicrophone(SwitchAudioOptions options) async {
await switchAudio(options);
}

Future<void> chooseCamera(SwitchVideoOptions options) async {
await switchVideo(options);
}

The root package does not publish a complete custom translation workspace. Keep translation inside the supplied room experience when enabled, and do not import modern implementation files as an application API.

Android 1.0.5

Use the Android room's media-settings workspace and current MediasfuGenericState rather than rebuilding the device pipeline. The Android publication includes platform virtual-background processing and room state for the chosen effect. Keep a clear None option and restore the unprocessed camera if processing fails.

Translation state and handlers apply only to a room configured for translation. Do not present them as an on-device transcription engine.

Kotlin Multiplatform 1.0.5

Kotlin exposes getMediaDevicesList, switchAudio, and switchVideo for input selection. The 1.0.5 room also supports audio-output routing through its media settings and switchAudioOutput platform boundary. VirtualBackgroundProcessor and the room's background state provide the platform effect boundary.

import com.mediasfu.sdk.methods.utils.getMediaDevicesList
import com.mediasfu.sdk.webrtc.MediaDeviceInfo

suspend fun availableInputs(): Pair<List<MediaDeviceInfo>, List<MediaDeviceInfo>> {
val cameras = getMediaDevicesList("videoinput")
val microphones = getMediaDevicesList("audioinput")
return cameras to microphones
}

Pass the chosen device through the active room's SwitchVideoOptions or SwitchAudioOptions; do not create a second room engine for the picker.

Translation models and receive handlers let an enabled room present received translation. They do not create a transcription provider or guarantee languages, accuracy, translated audio, or transcript storage.

Swift and Apple platforms 0.1.3

The hosted Apple room owns its supported camera, microphone, and room settings. Use the bridge toggles only after the hosted controller is mounted. The current Swift surface does not publish a standalone device picker, virtual-background processor, or translation workspace for an app-owned renderer.

Keep unsupported controls out of the Swift shell. Test permission changes, camera interruption, Bluetooth routes, and hosted-room cleanup on real devices.

Unity 0.1.0-preview.2

Unity exposes microphone and camera enablement, while the attached media backend owns device enumeration and routes.

await client.RequestMediaPermissionAsync(MediaSfuTrackKind.Audio);
await client.RequestMediaPermissionAsync(MediaSfuTrackKind.Video);
await client.SetMicrophoneEnabledAsync(true);
await client.SetCameraEnabledAsync(true);

The package does not publish a generic device picker, virtual-background processor, captions, or translation operation. Implement those only through a documented media-backend integration and keep a normal camera fallback.

Shared core 1.1.0

Shared core exports switchAudio, switchVideo, switchUserAudio, switchUserVideo, and launchBackground. It also exports received-subtitle and translation helpers such as createLiveSubtitle, updateLiveSubtitlesFromTranscript, and translationConsumerSwitch.

import {switchAudio, switchVideo} from 'mediasfu-shared';

export type AudioSwitch = Parameters<typeof switchAudio>[0];
export type VideoSwitch = Parameters<typeof switchVideo>[0];

Shared core supplies no picker, effect renderer, background processor, language menu, or transcription provider. The consuming framework must supply those UI and platform dependencies.

Release checklist

  • Permission denial leaves the room usable and offers a concrete retry.
  • Switching stops the old input only after the new input is active.
  • Remote participants receive the selected microphone and camera.
  • Front/back camera, Bluetooth, wired audio, and backgrounding are tested on every supported native platform.
  • Virtual backgrounds have None, failure, and low-performance fallbacks.
  • Translation controls appear only in enabled rooms.
  • Captions and translated audio are labelled distinctly.
  • Language availability and retention claims match the backend product.