File tree Expand file tree Collapse file tree 2 files changed +15
-14
lines changed Expand file tree Collapse file tree 2 files changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -106,23 +106,18 @@ struct ControlBar: View {
106106 let participantName = " user- \( Int . random ( in: 1000 ... 9999 ) ) "
107107
108108 do {
109- // Fetch connection details from token service
110- if let connectionDetails = try await tokenService. fetchConnectionDetails (
111- roomName: roomName,
112- participantName: participantName
113- ) {
114- // Connect to the room and enable the microphone
115- try await room. connect (
116- url: connectionDetails. serverUrl, token: connectionDetails. participantToken,
117- connectOptions: ConnectOptions ( enableMicrophone: true )
118- )
119- isConnecting = false
120- } else {
121- print ( " Failed to fetch connection details " )
109+ try await room. withPreConnectAudio {
110+ Task { @MainActor in isConnecting = false }
111+ // Fetch connection details from token service
112+ guard let connectionDetails = try await tokenService. fetchConnectionDetails ( roomName: roomName, participantName: participantName) else {
113+ print ( " Failed to fetch connection details " )
114+ return
115+ }
116+ // Connect to the room
117+ try await room. connect ( url: connectionDetails. serverUrl, token: connectionDetails. participantToken, connectOptions: . init( enableMicrophone: true ) )
122118 }
123119 } catch {
124120 print ( " Connection error: \( error) " )
125- isConnecting = false
126121 }
127122 }
128123 }
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ struct ContentView: View {
1616 let room = Room ( )
1717 _room = StateObject ( wrappedValue: room)
1818 _chatViewModel = State ( initialValue: ChatViewModel ( room: room, messageReceivers: TranscriptionStreamReceiver ( room: room) ) )
19+
20+ do {
21+ try AudioManager . shared. setRecordingAlwaysPreparedMode ( true )
22+ } catch {
23+ print ( " Failed to prepare recording " )
24+ }
1925 }
2026
2127 var body : some View {
You can’t perform that action at this time.
0 commit comments