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

<video> seems to get visibility:hidden; after change tab and back. #43

Closed
notalentgeek opened this issue Apr 16, 2017 · 5 comments
Closed

Comments

@notalentgeek
Copy link

notalentgeek commented Apr 16, 2017

Here are my HTML.

<div id="video_container" style="align-items:center;display:flex;height:100%;justify-content:center;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:2.5px;overflow:hidden;">
  <video id="video" width="50%" autoplay loop muted preload></video>
</div>

I am using the example codes.

let scanner = new Instascan.Scanner({ video: document.getElementById('video') });
scanner.addListener('scan', function (content) {
  console.log(content);
});
Instascan.Camera.getCameras().then(function (cameras) {
  if (cameras.length > 0) {
    scanner.start(cameras[0]);
  } else {
    console.error('No cameras found.');
  }
}).catch(function (e) {
  console.error(e);
});

Here is animated .gif of the problem. After I change tab (twice) the <video> gone although the DOM is still the same.

http://i.imgur.com/Qr4yp3E.gif

The screen shot of the <video> when it is gone.

http://i.imgur.com/vz7GcKt.png

@notalentgeek
Copy link
Author

Further doing, commenting //scanner.start(cameras[0]); remove the problem but also the QR scanner. What to do?

@notalentgeek
Copy link
Author

I use this QR reader along with face detection from TrackingJS. If I deactivate face tracking from TrackingJS the problem is gone.

What is my workaround if I need both face and QR detection?

@notalentgeek
Copy link
Author

Are these codes the culprit?

  _disableScan() {
    this.video.src = ''"

It makes the src goes unknown.

@notalentgeek
Copy link
Author

Alright, my bad... backgroundScan:true, fixes this.

@schmich
Copy link
Owner

schmich commented Apr 16, 2017

@notalentgeek Yep, sorry, just saw this issue. By default, scanning is disabled when the tab is not focused to save on CPU/power consumption, but you found the flag to disable that behavior.

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

2 participants