File tree 1 file changed +9
-10
lines changed
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 6060 > </ path >
6161 </ g >
6262 </ svg > </ button
63- > < br />
63+ >
6464 < button
6565 id ="switchCameraBtn "
6666 style ="background-color: transparent; border: none; cursor: pointer "
6767 >
6868 < svg
6969 xmlns ="http://www.w3.org/2000/svg "
70- style ="width: 40px ; height: 40px "
70+ style ="width: 60px ; height: 60px "
7171 height ="24 "
7272 viewBox ="0 0 24 24 "
7373 fill ="none "
9999 let currentStream ;
100100 let currentCamera = "front" ;
101101
102- // Show switch button if more than one camera
103- navigator . mediaDevices . enumerateDevices ( ) . then ( devices => {
104- const cameras = devices . filter ( device => device . kind === 'videoinput' ) ;
105- if ( cameras . length > 1 ) {
106- switchCameraBtn . style . display = "block" ;
107- }
108- } ) ;
109-
110102 // Request access to the webcam
111103 function startCamera ( ) {
112104 const constraints = {
119111 . then ( ( stream ) => {
120112 currentStream = stream ;
121113 video . srcObject = stream ;
114+ // Show switch button if more than one camera
115+ navigator . mediaDevices . enumerateDevices ( ) . then ( devices => {
116+ const cameras = devices . filter ( device => device . kind === 'videoinput' ) ;
117+ if ( cameras . length > 1 ) {
118+ switchCameraBtn . style . display = "block" ;
119+ }
120+ } ) ;
122121 } )
123122 . catch ( ( error ) => {
124123 console . error ( "Error accessing the camera:" , error ) ;
You can’t perform that action at this time.
0 commit comments