janpaul123 / paperprograms

Run Javascript on pieces of paper!

Home Page:https://paperprograms.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

video stream of webcam doesn't load

paulsonnentag opened this issue · comments

The webcam I'm using (Microsoft LifeCam 3000) doesn't work with Paper Programs. The "onloadedmetadata" event never get triggered. This problem unfortunately only occurs with Chrome (65.0.3325.181), other browsers work fine. The cause seems to be how getUserMedia is called:

navigator.mediaDevices
.getUserMedia({
audio: false,
video: {
width: { ideal: 100000 },
height: { ideal: 100000 },
},
})

If I change it to a specific resolution, my webcam supports it works. I think this is a bug with Chrome or the webcam driver.

video: { 
  width: 1280, 
  height: 720
}

I searched for a more generic solution which always picks the best available resolution and found this snippet on stack overflow. This also works with my webcam.

video: {
  optional: [
    {minWidth: 320},
    {minWidth: 640},
    {minWidth: 1024},
    {minWidth: 1280},
    {minWidth: 1920},
    {minWidth: 2560},
  ]
}

https://stackoverflow.com/questions/27420581/get-maximum-video-resolution-with-getusermedia#answer-27444179

Is this issue specific to my webcam or has anyone experienced something similar?

Fixed in #40 👍