question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't open Samsung S20 Camera

See original GitHub issue

Describe the bug I’ve implemented this plugin in my Angular project succesfully, also I’ve been able to test in some smartphones and it’s working great, but in my Samsung S20 I’m not able to open the camera. I’ve tried to check what cameras the plugin finds and it seems that it does find the back cameras, and I’ve also tried to implement the solution described in other bugs raised here but they don’t seem to fix mine.

Here’s the code that I’ve implemented: `camerasFoundHandler(e) { this.availableDevices = e; this.hasDevices = Boolean(e && e.length); console.dir(e);

let backCams = this.availableDevices.filter((c) => c.label.includes('back')); 
console.dir(backCams);
if (backCams.length > 0) { 
  this.currentDevice = backCams[0]; 
} else { 
  this.currentDevice = this.availableDevices[0]; 
}
setTimeout(() => {
  this.enableScanner = true;
  console.dir(this.currentDevice);
  setTimeout(() => {
    this.th = true; // This is to enable the tryHarder
  }, 1000);
}, 1000);

}`

I’ve also tried to run through all the cameras trying to open one by one with the following function: myLoop(devices){ setTimeout(() => { console.dir(devices[this.controller]); this.currentDevice = devices[this.controller]; this.controller++; if (this.controller < devices.length) { this.myLoop(devices); } }, 3000); }

but it throws an error that says “Uncaught (in promise): Error: No scanning is running at the time.” Expected behavior The camera should open

Smartphone (please complete the following information):

  • Device: Samsung S20
  • OS: Android 11
  • Browser: Google Chrome latest version

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
r3plicacommented, Apr 26, 2021

any updates on this guys?

1reaction
r3plicacommented, Apr 1, 2021

I can also confirm that this is not working. I have gone through all the other issues raised and tried all the solutions presented and they haven’t worked. I am now in the process of testing the API itself. I have written this code (as a test)

  private listDevices(): void {
    let n: any = navigator;
    let v: ElementRef = this.video;

    // Older browsers might not implement mediaDevices at all, so we set an empty object first
    if (n.mediaDevices === undefined) {
      n.mediaDevices = {};
    }

    // Some browsers partially implement mediaDevices. We can't just assign an object
    // with getUserMedia as it would overwrite existing properties.
    // Here, we will just add the getUserMedia property if it's missing.
    if (n.mediaDevices.getUserMedia === undefined) {
      n.mediaDevices.getUserMedia = function (
        constraints: MediaStreamConstraints
      ) {
        // First get ahold of the legacy getUserMedia, if present
        var getUserMedia = n.webkitGetUserMedia || n.mozGetUserMedia;

        // Some browsers just don't implement it - return a rejected promise with an error
        // to keep a consistent interface
        if (!getUserMedia) {
          return Promise.reject(
            new Error('getUserMedia is not implemented in this browser')
          );
        }

        // Otherwise, wrap the call to the old n.getUserMedia with a Promise
        return new Promise(function (resolve, reject) {
          getUserMedia.call(n, constraints, resolve, reject);
        });
      };
    }

    n.mediaDevices
      .getUserMedia({ audio: false, video: true })
      .then(function (stream: MediaStream) {
        v.nativeElement.srcObject = stream;
      })
      .catch(function (err: MediaStreamError) {
        console.log(err.name + ': ' + err.message);
      });
  }

And this works on my phone (s20)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Galaxy S20 Camera Not Working? Here's The Fix!
Here's how it's done: 1. Go to the screen where the Camera icon is located. 2. Tap and hold on the Instagram icon...
Read more >
Issues with Camera app on Samsung phone or tablet
Open the camera app. Open the Camera app, and then tap Settings. · Reset the settings. Swipe to and tap Reset settings, and...
Read more >
How to Fix Camera Issues on Samsung Galaxy S20,S20+,S20 ...
Go to Settings; Next, tap on Apps; Navigate to Camera app and tap on it ; Open the Apps tray from the Home...
Read more >
Samsung S21/S20/S10 Camera Failed-7 Quick Fixes
Way 1: Force Restart Your Phone to Fix Samsung Camera Failed · Press and hold the "Power" as well as "Volume down" button...
Read more >
Your Samsung S20 Camera Not Working? | GET iT FiXT
Your Samsung S20 Camera Not Working? · 2. Clear app cache. Follow it by clearing the app's cache. · 3. Forced Reboot. Restart...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found