简体   繁体   中英

How to switch frontface camera to backface camera via videojs-record for image capturing?

This works for video (With the code snippet camera changes to backface camera)

 videoPlayer.record().stopDevice();
 videoPlayer.record().setVideoInput('backface-camera-device-id');

But analogically for image doesn't change anything. Camera still the same (Only frontface camera)

 imagePlayer.record().stopDevice();
 imagePlayer.record().setVideoInput('backface-camera-device-id');

My options for imagePlayer is

const options = {
                controls: true,
                width: width,
                height: height,
                controlBar: {
                    volumePanel: true
                },
                plugins: {
                    record: {
                        image: true,
                        imageOutputType: 'blob',
                        mandatory: {
                            minWidth: 1280,
                            minHeight: 720,
                        },
                        frameWidth: 1280,
                        frameHeight: 720,
                    }
                }
            };
const imagePlayer = videojs('image-frame', options);

Image frame is

<video id="image-frame"></video>

My video options (works only with video)

const options = {
                controls: true,
                width: width,
                height: height,
                fluid: false,
                controlBar: {
                    volumePanel: false,
                    cameraButton: true,
                },
                plugins: {
                    record: {
                        audio: true,
                        video: true,
                        videoEngine: 'recordrtc',
                        maxLength: 120,
                        debug: true,
                        mandatory: {
                            minWidth: 1280,
                            minHeight: 720,
                        },
                        frameWidth: 1280,
                        frameHeight: 720,
                        timeSlice: 1000
                    }
                }
            };

Glad to any help or clue to solve the camera switching problem!

imagePlayer.record().recordImage = {deviceId: {exact: 'backface-camera-device-id'}};
imagePlayer.record().stopDevice();
imagePlayer.record().getDevice();

worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM