@@ -112,11 +112,28 @@ type ResizeCallback = (event: Event, arg1: Rectangle) => void;
112112
113113let currentResizeHandler : ResizeCallback | null = null
114114
115+ /**
116+ * If id and name are provided, passes the id and name to the webcam popout so that the given
117+ * video stream is rendered. If id or name are not provided, prevents any video streams from
118+ * being rendered on the window so that the webcam is not showing in the background
119+ * @param id The device stream ID
120+ * @param name The name of the device
121+ */
122+ function loadWebcam ( id : string = "" , name : string = "" ) {
123+
124+ const params : string = id && name ? "/webcam?deviceId=" + id + "&deviceName=" + name : "/webcam" ;
125+
126+ if ( VITE_DEV_SERVER_URL )
127+ webcamPopoutWin ?. loadURL ( VITE_DEV_SERVER_URL + "#" + params )
128+ else
129+ webcamPopoutWin ?. loadFile ( path . join ( process . env . DIST , 'index.html' ) , { hash : params } )
130+ }
131+
115132function openWebcamPopout ( videoStreamId : string , name : string , aspect : number ) {
116133
117134 if ( webcamPopoutWin === null ) return ;
135+ loadWebcam ( videoStreamId , name ) ;
118136
119- webcamPopoutWin . loadURL ( "http://localhost:5173/#/webcam?deviceId=" + videoStreamId + "&deviceName=" + name ) ;
120137 webcamPopoutWin . setTitle ( name ) ;
121138
122139 // Remove previous resize handler
@@ -150,7 +167,7 @@ function openWebcamPopout(videoStreamId: string, name: string, aspect: number){
150167
151168function closeWebcamPopout ( ) {
152169 webcamPopoutWin ?. hide ( )
153- webcamPopoutWin ?. loadURL ( "http://localhost:5173/#/webcam" )
170+ loadWebcam ( ) ;
154171 win ?. webContents . send ( "webcam-closed" ) ;
155172}
156173
@@ -210,7 +227,10 @@ function createWindow() {
210227 fullscreen : false ,
211228 fullscreenable : false ,
212229 } ) ;
213- webcamPopoutWin . loadURL ( "http://localhost:5173/#/webcam" )
230+
231+
232+ // We load the webcam route here to prevent having to load the page on popout
233+ loadWebcam ( ) ;
214234
215235 // Open links in browser, not within the electron window.
216236 // Note, links must have target="_blank"
0 commit comments