@@ -21,7 +21,6 @@ export class ScreenCaptureDevice {
2121 #isRecording = false ;
2222 #isOn = false ;
2323 #isAudioChecked = false ;
24- #isVideoChecked = false ;
2524
2625 /**
2726 * Constructor for a ScreenCaptureDevice object that captures stream of video/audio from user screens & windows.
@@ -145,6 +144,17 @@ export class ScreenCaptureDevice {
145144 if ( ! this . #isOn) {
146145 let constraints = { audio : false , video : false } ;
147146
147+ constraints . video = {
148+ mandatory : {
149+ chromeMediaSource : 'desktop' ,
150+ chromeMediaSourceId : source . id ,
151+ minWidth : 1280 ,
152+ maxWidth : this . #videoResolutionWidth,
153+ minHeight : 720 ,
154+ maxHeight : this . #videoResolutionHeight
155+ }
156+ } ;
157+
148158 if ( this . #isAudioChecked) {
149159 constraints . audio = {
150160 mandatory : {
@@ -153,30 +163,17 @@ export class ScreenCaptureDevice {
153163 } ;
154164
155165 }
156- if ( this . #isVideoChecked) {
157- constraints . video = {
158- mandatory : {
159- chromeMediaSource : 'desktop' ,
160- chromeMediaSourceId : source . id ,
161- minWidth : 1280 ,
162- maxWidth : this . #videoResolutionWidth,
163- minHeight : 720 ,
164- maxHeight : this . #videoResolutionHeight
165- }
166- } ;
167- }
168166
169167 try {
170168 var stream = await navigator . mediaDevices . getUserMedia ( constraints )
171- videoElement . srcObject = stream ;
169+ this . # videoElement. srcObject = stream ;
172170
173171 } catch ( error ) {
174- console . log ( error ) ;
172+ console . log ( "STARTCAPTURE:" + error ) ;
175173 return false ;
176174 }
177175
178176 this . #isOn = true ;
179- this . checkmarkRecordHelper ( recordInclusionContainer )
180177 return true ;
181178 }
182179 }
@@ -255,7 +252,6 @@ export class ScreenCaptureDevice {
255252 let onElement = document . createElement ( "button" ) ;
256253 let offElement = document . createElement ( "button" ) ;
257254 let aVCheckContainer = document . createElement ( "div" ) ;
258- let videoCheckContainer = document . createElement ( "div" ) ;
259255 let audioCheckContainer = document . createElement ( "div" ) ;
260256 let fileNameContainer = document . createElement ( "div" ) ;
261257 let recordInclusionContainer = document . createElement ( "div" ) ;
@@ -326,7 +322,6 @@ export class ScreenCaptureDevice {
326322
327323 // Build aVCheckContainer
328324 aVCheckContainer . classList . add ( "av-check-container" ) ;
329- videoCheckContainer . classList . add ( "av-inner-container" ) ;
330325 audioCheckContainer . classList . add ( "av-inner-container" ) ;
331326
332327 var checkImgVideo = document . createElement ( "img" ) ;
@@ -341,9 +336,6 @@ export class ScreenCaptureDevice {
341336 videoNameDiv . innerText = "Video:" ;
342337 videoNameDiv . classList . add ( "general-txt" ) ;
343338 videoNameDiv . classList . add ( "av-label" ) ;
344- let videoCheckBoxContainer = document . createElement ( "div" ) ;
345- videoCheckBoxContainer . classList . add ( "av-checkbox" ) ;
346- videoCheckBoxContainer . appendChild ( checkImgVideo ) ;
347339
348340 let audioNameDiv = document . createElement ( "div" ) ;
349341 audioNameDiv . innerText = "Audio:" ;
@@ -353,21 +345,14 @@ export class ScreenCaptureDevice {
353345 audioCheckBoxContainer . classList . add ( "av-checkbox" ) ;
354346 audioCheckBoxContainer . appendChild ( checkImgAudio ) ;
355347
356- videoCheckContainer . addEventListener ( "click" , ( evt ) => {
357- this . checkmarkVideoHelper ( evt . currentTarget ) ;
358- } ) ;
359-
360348 audioCheckContainer . addEventListener ( "click" , ( evt ) => {
361349 this . checkmarkAudioHelper ( evt . currentTarget ) ;
362350 } ) ;
363351
364352 // ! Final step for aVCheckContainer - add a decibel meter below audio option for live monitoring.
365353
366- videoCheckContainer . appendChild ( videoNameDiv ) ;
367- videoCheckContainer . appendChild ( videoCheckBoxContainer ) ;
368354 audioCheckContainer . appendChild ( audioNameDiv ) ;
369355 audioCheckContainer . appendChild ( audioCheckBoxContainer ) ;
370- aVCheckContainer . appendChild ( videoCheckContainer ) ;
371356 aVCheckContainer . appendChild ( audioCheckContainer ) ;
372357
373358 // Build on/off buttons
@@ -412,45 +397,19 @@ export class ScreenCaptureDevice {
412397 videoContainer . appendChild ( videoButtonsContainer ) ;
413398
414399 // Autostart screen capture with all options selected
415- this . checkmarkVideoHelper ( videoCheckContainer ) ;
416400 this . checkmarkAudioHelper ( audioCheckContainer ) ;
401+ this . checkmarkRecordHelper ( recordInclusionContainer ) ;
417402 this . displaySourceOptions ( recordInclusionContainer ) ;
418403
419404 return videoContainer ;
420405 }
421406
422407 clearUI ( ) {
423- this . #isVideoChecked = false ;
424408 this . #isAudioChecked = false ;
425409 this . #isRecordOptionChecked = false ;
426410 return ;
427411 }
428412
429- /**
430- * Reveal/hide target's checkmark img, set boolean value of video to true.
431- *
432- * @param {HTML Div Element } elementContainer - Container of multiple child elements where checkmark image is
433- * held as childNode[1]->childNode[0] from elementContainer.
434- */
435- checkmarkVideoHelper ( elementContainer ) {
436- // Check video section with visible check mark and bool in class
437- if ( ! this . #isOn && ! this . #isVideoChecked) {
438- // Preview is off and video isn't checked, so check
439-
440- elementContainer . childNodes [ 1 ] . childNodes [ 0 ] . style . visibility = "visible" ;
441- this . #isVideoChecked = true ;
442-
443- } else if ( ! this . #isOn && this . #isVideoChecked) {
444- // Preview is off and video isn't checked, so check
445- elementContainer . childNodes [ 1 ] . childNodes [ 0 ] . style . visibility = "hidden" ;
446- this . #isVideoChecked = false ;
447-
448- } else {
449- // Preview is on while changing, send error
450- console . log ( "Error: Can't change sources when stream is live." ) ;
451- }
452- }
453-
454413 /**
455414 * Reveal/hide target's checkmark img, set boolean value of audio to true.
456415 *
@@ -484,13 +443,13 @@ export class ScreenCaptureDevice {
484443 */
485444 checkmarkRecordHelper ( elementContainer ) {
486445 // Check record section with visible check mark and bool in class
487- if ( this . #isOn && ! this . #isRecordOptionChecked && ! this . #isRecording) {
446+ if ( ! this . #isRecordOptionChecked && ! this . #isRecording) {
488447 // Preview is on (live) and record isn't checked and not currently recording, so check
489448
490449 elementContainer . childNodes [ 1 ] . childNodes [ 0 ] . style . visibility = "visible" ;
491450 this . #isRecordOptionChecked = true ;
492451
493- } else if ( this . #isOn && ! this . #isRecording) {
452+ } else if ( this . #isRecordOptionChecked && ! this . #isRecording) {
494453 // Preview is off and record isn't checked, so check
495454 elementContainer . childNodes [ 1 ] . childNodes [ 0 ] . style . visibility = "hidden" ;
496455 this . #isRecordOptionChecked = false ;
0 commit comments