ReVue KITSwift reference Guides

Instance Method

set(source:enabled:captureOptions:)

開關一個來源的硬體擷取:等同對應的 setCamera/setMicrophone/setScreenShare

@discardableResult @MainActor func set(source: Track.Source, enabled: Bool, captureOptions: CaptureOptions? = nil) async throws -> [LocalTrackPublication]

Parameters

source

.camera / .microphone / .screenShareVideo

enabled

true = 開硬體擷取、false = 關硬體擷取

captureOptions

.camera 收 CameraCaptureOptions、.screenShareVideo 收 ScreenShareCaptureOptions; nil 或型別不符時用預設值

Return Value

這條軌道目前的 publication(每位接收者一份;沒有發布則為空)

Discussion

只開關硬體,不改任何 isMuted(軌道的、publication 的都不改),也不負責 publish。 要讓接收者收到佔位畫面或靜音、硬體繼續跑,用軌道的 mute()(例如 microphoneTrack.mute()); 只對某一位停送,用那一份的 LocalTrackPublication.mute()。

source等同
.camerasetCamera(enabled:options:):captureOptions 是 CameraCaptureOptions 時轉交 options;關閉時每位接收者收到佔位畫面
.microphonesetMicrophone(enabled:):開關麥克風硬體(AudioManager 依此切換 AudioSession category);不讀 captureOptions
.screenShareVideosetScreenShare(enabled:):關閉時停止擷取、每位接收者收到佔位畫面,不撤下發布;收 ScreenShareCaptureOptions,欄位目前還沒有作用

關螢幕分享會 unpublish。RevueSDK 的硬體開關與 mute 分開,每個入口只管一件事。

開不起來時:.camera 只記 log、isCameraActive 改回 false,不丟錯(同 setCamera); .screenShareVideo 丟出 setScreenShare(enabled:) 的錯誤。

// 關麥克風硬體(例如要預覽錄影檔,AudioSession 可切回 .playback)
try await localParticipant.set(source: .microphone, enabled: false)

// 靜音但硬體繼續跑:mute 軌道,所有接收者收到全 0 的聲音
try await localParticipant.microphoneTrack.mute()

Throws

  • RoomMessageError.unsupportedSource — 收到不支援的 source(例如 .unknown)

  • .screenShareVideo:setScreenShare(enabled:) 丟出的錯誤(例如螢幕錄製權限被拒)

Note

@MainActor:轉給的 setCamera、setMicrophone、setScreenShare 會寫 @Published 狀態與出口,一律在 main(standard apple/0006)。