Code Monkey home page Code Monkey logo

Comments (5)

odahcam avatar odahcam commented on August 10, 2024

It's a nice feature, but maybe it's not responsability of the scanner itself. Let's discuss about the architecture we gonna take for that before taking any premature decision.

  • Changing the MediaStream to readonly is possible.
  • I would not like to add more logic inside the startDecodeFromStream method, it is already too big.
  • Maybe some refactor will be needed the same way I did with the component class for v1.
let torcherFunction = stream => {

    // Get track for image capture
    const track = stream.getVideoTracks()[0];

    // Create image capture object and get camera capabilities
    const imageCapture = new ImageCapture(track)
    const photoCapabilities = imageCapture.getPhotoCapabilities().then(() => {

        // todo: check if camera has a torch

        // let there be light!
        track.applyConstraints({
            advanced: [{
                torch: true
            }]
        });

    });
};
  • Do we need the imageCapture.getPhotoCapabilities or can we work directly on the track object?
  • Feel free to add more points. 😀

from ngx-scanner.

csutorasr avatar csutorasr commented on August 10, 2024

Sorry, as stream is being saved, only a new function is needed called setTorch. It should contain the code to set the torch on and off.

It would be better, if the startDecode function would be separated into private parts like bindSrc, bindEvents, checkTorchCombatibility (as it is needed to be checked once). A property could be saved to show torch compatibility.

setTorch checks if torch can be activated through the variable and sets on/off it.

Maybe instead of a variable an event would be better, as from the component it is easier to bind values to events.

Edit:
I would add it into the scanner, as it is really a workaround to set/get values of components in Angular. A compontent should not be modified from outside.

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

Sorry, as stream is being saved, only a new function is needed called setTorch. It should contain the code to set the torch on and off.

I like that.

I would add it into the scanner, as it is really a workaround to set/get values of components in Angular. A compontent should not be modified from outside.

I did not remember very well how their logic is separated, sorry, I gotta take a look again to see what insights I will have. xD

I work with a lot of things at the same, so sorry if I misundertood.

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

Closing as merged.

from ngx-scanner.

lock avatar lock commented on August 10, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from ngx-scanner.

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.