Giter Site home page Giter Site logo

Comments (5)

bitjson avatar bitjson commented on May 11, 2024

Hey @gitmh, thanks for the report! That's something I've not considered. Does the rotation matter when scanning QR codes? (Does it scan differently?) How do you think the plugin should handle device orientation?

from cordova-plugin-qrscanner.

gitmh avatar gitmh commented on May 11, 2024

I have a cordova app which is fixed to landscape only. The scanning also works without rotation but it is very annoying to "find" the code if you move left and the preview moves right and vice versa because the video preview is rotated 180° on your screen (up is down and down is up).

I'm not very familiar with Swift so I tried to fix this by adding something like this:

        let app = UIApplication.sharedApplication()
        switch app.statusBarOrientation {
        case .Portrait:
            captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.Portrait;
        case .PortraitUpsideDown:
            captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.PortraitUpsideDown;
        case .LandscapeLeft:
            captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.LandscapeLeft;
        case .LandscapeRight:
            captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.LandscapeRight;
        default:
            captureVideoPreviewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.LandscapeRight;
        }

I managed to solve the issue with a NSTimer calling an additional function adjustCameraOrientation. It also needs to resize the frame of the UIView and the previewLayer to work properly on rotation. My current code is here: https://www.dropbox.com/s/ll24xadtgrpbolb/QRScanner.swift?dl=0

Maybe a timer is not a proper solution for this problem, sorry I never used Swift before.

from cordova-plugin-qrscanner.

bitjson avatar bitjson commented on May 11, 2024

Hey @gitmh, thanks again for the report. Just wanted to let you know that I'm currently finishing up with the browser implementation (#6), but this is on my radar. I plan to take a swing at this issue once the initial browser implementation is merged.

from cordova-plugin-qrscanner.

bitjson avatar bitjson commented on May 11, 2024

Still looking at this – I added some device orientation controls to the manual tests to help with testing for this issue: d9a11cd#diff-2a8a5fef3397df87ab538f028a5c6b50R96

I'm not very familiar with iOS's layout system – I think the best solution is to disable orientation changes on just the video preview layer (such that the camera always stays oriented with the screen as the device is rotated). I've not been able to get a working solution yet – pull requests welcome!

from cordova-plugin-qrscanner.

gitmh avatar gitmh commented on May 11, 2024

@bitjson I also very unfamiliar with this orientation stuff. The solution I mentioned in the dropbox link with a timer works very well in my app. The problem is that I was unable to register a proper event handler for the orientation change.

from cordova-plugin-qrscanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.