switch camera using MediaDevices.getUserMedia() in webrtc

后端 未结 3 1625
失恋的感觉
失恋的感觉 2020-12-11 17:54

I am trying navigator.MediaDevices.getUserMedia() webrtc to switch the device camera during the call. This functionality is working fine on the desktop browser but on mozil

相关标签:
3条回答
  • 2020-12-11 18:33

    Phone hardware typically doesn't allow opening both the front and back camera at the same time. Change your code to stop() the existing stream before getting the other camera.

    See my answer to a similar question for a working example.

    0 讨论(0)
  • 2020-12-11 18:38

    use the last version of adapter.js and see if NotReadableerror is happening, it seems that Chrome for android cannot release front camera hardware to switch to rear by using stream.getVideoTracks()[0].stop(); I think it could be a bug

    0 讨论(0)
  • 2020-12-11 18:40
    Webcam.set({
            width: 490,
            height: 450,
            image_format: 'jpeg',
            jpeg_quality: 90,
            constraints: {
                        facingMode: {
                                      exact: 'environment'
                                      }
    
                    }   
        });
    

    This code is working for all browsers.

    constraints: {facingMode: { exact: 'environment' }} 
    

    Above line is responsible to open rear camera, set constraints : null to open front camera. you can also adjust this code by implementing "switch camera" button method

    0 讨论(0)
提交回复
热议问题