Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't switch between webcams in image-only mode #643

Open
DKRL opened this issue Mar 25, 2022 · 0 comments
Open

Can't switch between webcams in image-only mode #643

DKRL opened this issue Mar 25, 2022 · 0 comments

Comments

@DKRL
Copy link

DKRL commented Mar 25, 2022

Description

I can't switch between two webcams in image-only mode.

Steps to reproduce

Just use one of your default examples with two webcams and this config:

const videoJsOptions = {
  controls: false,
  bigPlayButton: false,
  fluid: false,
  fill: true,
  width: 640,
  height: 480,
  plugins: {
    record: {
      debug: true,
      imageOutputType: 'dataURL',
      imageOutputFormat: 'image/png',
      imageOutputQuality: 0.92,
      image: true,
      // video: true
    },
  },
}

And then just try to switch between them calling setVideoInput(deviceId)

Results

Expected

Video should switch to another webcam.

Actual

Have same webcam loaded or just an error (in 30-50% of tries).

Error output

DOMException: Failed to allocate videosource

Possible reason and solution

DeviceId is set in setVideoInput method only for video, not for image mode.

I made a simple workaround by implementing setImageInput method, just like setVideoInput:

setImageInput(deviceId) {
    if (this.recordImage === Object(this.recordImage)) {
        // already using image constraints
        this.recordImage.deviceId = {exact: deviceId};

    } else if (this.recordImage === true) {
        // not using image constraints already, so force it
        this.recordImage = {
            deviceId: {exact: deviceId}
        };
    }

    // release existing device
    this.stopDevice();

    // ask for video input device permissions and start device
    this.getDevice();
}

Additional Information

versions

videojs

videojs-record: 4.5.0

browsers

firefox, chrome, electron

OSes

windows

Sorry, I'm not a native English speaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant