File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ final class DeviceSwitcher: ObservableObject {
4242        observeDevices ( ) 
4343    } 
4444
45+     convenience init ( agentSession:  AgentSession )  { 
46+         self . init ( room:  agentSession. _room) 
47+     } 
48+ 
4549    private  func  observeRoom( )  { 
4650        Task  {  [ weak self]  in 
4751            guard  let  changes =  self ? . room. changes else  {  return  } 
Original file line number Diff line number Diff line change @@ -6,14 +6,15 @@ struct VoiceAgentApp: App {
66    // To use the LiveKit Cloud sandbox (development only)
77    // - Enable your sandbox here https://cloud.livekit.io/projects/p_/sandbox/templates/token-server
88    // - Create .env.xcconfig with your LIVEKIT_SANDBOX_ID
9-     private  let  sandboxID =  Bundle . main. object ( forInfoDictionaryKey:  " LiveKitSandboxId " )  as!  String 
10-     private  let  room =  Room ( roomOptions:  RoomOptions ( defaultScreenShareCaptureOptions:  ScreenShareCaptureOptions ( useBroadcastExtension:  true ) ) ) 
9+     private  static  let  sandboxId =  Bundle . main. object ( forInfoDictionaryKey:  " LiveKitSandboxId " )  as!  String 
10+     private  let  session =  AgentSession ( credentials:  Sandbox ( id:  Self . sandboxId) , 
11+                                        room:  Room ( roomOptions:  RoomOptions ( defaultScreenShareCaptureOptions:  ScreenShareCaptureOptions ( useBroadcastExtension:  true ) ) ) ) 
1112
1213    var  body :  some  Scene  { 
1314        WindowGroup  { 
1415            AppView ( ) 
15-                 . environmentObject ( DeviceSwitcher ( room :  room ) ) 
16-                 . environmentObject ( AgentSession ( credentials :   Sandbox ( id :  sandboxID ) ,  room :  room ) ) 
16+                 . environmentObject ( session ) 
17+                 . environmentObject ( DeviceSwitcher ( agentSession :  session ) ) 
1718        } 
1819        #if os(macOS) 
1920        . defaultSize( width:  900 ,  height:  900 ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments