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

Camera Facing Setting #79

Open
rickyok opened this issue Nov 28, 2022 · 0 comments
Open

Camera Facing Setting #79

rickyok opened this issue Nov 28, 2022 · 0 comments

Comments

@rickyok
Copy link

rickyok commented Nov 28, 2022

Hi, i really like your plugin, really works well in my project.

I have one suggestion, if you don't mind. Please make config to select the camera facing for "environment" or "user".
Especially for web.

I kinda hardcoded specific for my case in qr_code_scanner_web_impl.dart

    // find out what device this apps is running from
    String facingMode = "environment"; // default
    try {
      final userAgent = html.window.navigator.userAgent.toString()
          .toLowerCase();
      if (userAgent.contains('iphone'))
        facingMode = 'environment';
      else if (userAgent.contains('ipad'))
        facingMode = 'user';
      else if (userAgent.contains('macintosh'))
        facingMode = 'user';
      else if (userAgent.contains('android')) facingMode = 'environment';
    }
    catch (err) {
      // do nothing
    }

    // Access the webcam stream
    try {
      html.window.navigator.mediaDevices?.getUserMedia({
        'video': {'facingMode': facingMode}
      }).then((html.MediaStream stream) {
        _stream = stream;
        _video.srcObject = stream;
        _video.setAttribute('playsinline',
            'true'); // required to tell iOS safari we don't want fullscreen
        _video.play();
      });
    } catch (err) {
      print(err);
      //Fallback
      try {
        html.window.navigator
            .getUserMedia(video: {'facingMode': facingMode}).then(
                (html.MediaStream stream) {
          _stream = stream;
          _video.srcObject = stream;
          _video.setAttribute('playsinline',
              'true'); // required to tell iOS safari we don't want fullscreen
          _video.play();
        });
      } catch (e) {
        print(e);
      }
    }

I wanna push request myself. But i'm really new into flutter, and haven't learn how to send parameter from the parent plugin to the web implementation.

I want to make some paremeter to pass like

PlatformAiBarcodeScannerWidget(platformScannerController: _scannerController, facing: 'user')

Thanks

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