Skip to content

Camera Facing Setting #79

@rickyok

Description

@rickyok

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions