goergch / angular2-qrscanner Goto Github PK
View Code? Open in Web Editor NEWAn angular 2 qr code scanner
License: GNU General Public License v3.0
An angular 2 qr code scanner
License: GNU General Public License v3.0
What is this?
This behavior was, is and will be unacceptable in any case.
The script failed to handle the scenario of a system not having camera device attached to it.
The stopScanning() function attempts to blindly turn off the tracks acquired by stream without confirming if the stream is not null or undefined.
Pondering about switching the library I have been using since last few days.
Thanks for rigorous support in helping me solve the issues about the library.
please add reverted code.
if (this.stream.getTracks().length > 0) { this.stream.getTracks()[0].stop(); }
at line 107 qrscanner.component.ts
this.initCanvas(this.canvasHeight, this.canvasWidth);
Where the initCanvas function receives the following parameters:
private initCanvas(w: number, h: number): void {
When I import this module,
And use subscribe or forEach,
return resource will got additional function:remove
How could I add the animation of the red bar that runs through the reader, something like the whatsapp reader?
OnRead event not triggering,
<qr-scanner [debug]="true" [mirror]="true" (onRead)="decodedOutput($event)"></qr-scanner>
debug,mirror and other canvas size attributes are working, but onRead not working.
In my-component.ts
`ngOnInit() {
}
decodedOutput($event: string) {
alert();
console.log('Decoded', $event);
}`
Hi I want to know how to set back camera as default
There is a way to make it works with Ios / Android ?
The current logic to switch camera's on mobile devices works very well for Android but not for iOS. The reason is that Safari only supports the 'new' way of switching camera's on mobile devices.
I have a nice workaround that works with this library. Below is an example way of selecting another camera. The magic is inside the facingMode constraint. 'setStream' is private in the library so I'm casting to to circumvent this restriction. Sorry for this hack ;-)
I guess it would be fairly easy to integrate this logic into this library.
changeDevice(event: MatSelectChange) {
const device = this.availableVideoDevices.filter(device => device.deviceId === event.value)[0];
if (navigator.platform && (navigator.platform.toLowerCase().includes('ipad') || navigator.platform.toLowerCase().includes('iphone'))) {
if (device.label.toLowerCase().includes('back')) {
navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: { exact: "environment" } } }).then(stream => {
(<any>this.qrScannerComponent).setStream(stream);
});
} else {
navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: "user" }}).then(stream => {
(<any>this.qrScannerComponent).setStream(stream);
});
}
} else {
this.qrScannerComponent.chooseCamera.next(device);
}
Hello,
I'm trying to import QrScannerModule
into my Angular-CLI app, and when I do, I get the following ERROR in /Users/Garve/projects/ticketsurge-client/node_modules/angular2-qrscanner/src/qrdecode/version.ts (173,28): Block-scoped variable 'buildVersions' used before its declaration.
I haven't imported it into an Angular module yet, just imported into the file and I get this error in the build system.
OS: Mac
CLI: 1.4.3
@angular/*: 4.3.1
typescript: 2.2.2
node: v8.2.1
yarn: 1.2.0
I can provide more detail if needed. Thank you!
If I specify [stopAfterScan]="false"
on the component and provide the default [updateTime]="500"
, the onRead
callback only fires twice and then nothing happens. Nothing more is scanned.
I also tried various update times both> 500
and < 500
and sometimes I got one scan, sometimes two, but never more than two.
In the case of the update time being 500, I did some debugging in qrcode.js
inside of the node module, and it looks like after the second scan, both the process
and decode
methods stop firing.
Perhaps this is a weird setTimeout
issue?
Thanks!
Thanks for this library.
I am trying it from a ios 11.2 safari browser. Somehow, it is not able to open the camera. Once I allow the camera, It is showing black screen.
We get Metadata error which is hindering our deployments. As it does not allow ng build. Below is the configuration ; followed by full error trace.
Kindly help us.
angular2-qrscanner version: 1.0.7
Angular CLI: 1.5.0
Node: 8.10.0
OS: win32 x64
Angular: 4.3.2
... common, compiler, compiler-cli, core, forms, http
... platform-browser, platform-browser-dynamic, router
@angular/animations: 4.4.0-RC.0
@angular/cdk: 2.0.0-beta.10
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.8
@angular/material: 2.0.0-beta.10
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.3
typescript: 2.6.1
webpack: 3.8.1
ERROR in Error: Metadata version mismatch for module <Angular4.3-AppPath>/node_modules/angular2-qrscanner/angular2-qrscanner.d.ts, found version 4, expected 3, resolving symbol <Module_Name>in <Angular4.3-AppPath>/src/app/modules/manage/device/device.module.ts, resolving symbol <Module_Name>in <Angular4.3-AppPath>/src/app/<Module_Path>.ts
at syntaxError (<Angular4.3-AppPath>\node_modules@angular\compiler\bundles\compiler.umd.js:1725:34)
at simplifyInContext (<Angular4.3-AppPath>\node_modules@angular\compiler\bundles\compiler.umd.js:24953:23)
at StaticReflector.simplify (<Angular4.3-AppPath>\node_modules@angular\compiler\bundles\compiler.umd.js:24965:13)
at StaticReflector.annotations (<Angular4.3-AppPath>\node_modules@angular\compiler\bundles\compiler.umd.js:24395:41)
at _getNgModuleMetadata (<Angular4.3-AppPath>\node_modules@angular\compiler-cli\src\ngtools_impl.js:138:31)
at _extractLazyRoutesFromStaticModule (<Angular4.3-AppPath>\node_modules@angular\compiler-cli\src\ngtools_impl.js:109:26)
at <Angular4.3-AppPath>\node_modules@angular\compiler-cli\src\ngtools_impl.js:129:27
at Array.reduce ()
at _extractLazyRoutesFromStaticModule (<Angular4.3-AppPath>\node_modules@angular\compiler-cli\src\ngtools_impl.js:128:10)
at Object.listLazyRoutesOfModule (<Angular4.3-AppPath>\node_modules@angular\compiler-cli\src\ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (<Angular4.3-AppPath>\node_modules@angular\compiler-cli\src\ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (<Angular4.3-AppPath>\node_modules@ngtools\webpack\src\plugin.js:241:66)
at _donePromise.Promise.resolve.then.then.then.then.then (<Angular4.3-AppPath>\node_modules@ngtools\webpack\src\plugin.js:495:24)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
webpack: Failed to compile.
Hello Everyone,
since i've updated to Angular 5, when i get to build with --aot or --prod flag i get this error :
ERROR in ./node_modules/angular2-qrscanner/src/qrscanner.component.ngfactory.ts
Module build failed: Error: D:\Workplace\dancematik\node_modules\angular2-qrscanner\src\qrscanner.component.ngfactory.ts is missing from the TypeScript compilation. Please make sure
it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (D:\Workplace\dancematik\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:662:23)
at plugin.done.then (D:\Workplace\dancematik\node_modules@ngtools\webpack\src\loader.js:467:39)
at
@ ./src/app/leggiticket/leggiticket.component.ngfactory.js 8:0-97
@ ./src/app/app.module.ngfactory.js
@ ./src/main.ts
@ multi ./src/main.ts
As far as you know... there is some issue with this component and Angular 5 ?
i've tried also the vNext branch... but i get the same issue...
This is my package.json
"name": "ara.web-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@amcharts/amcharts3-angular": "^1.5.0",
"@angular/animations": "^5.2.11",
"@angular/common": "^5.2.11",
"@angular/compiler": "^5.2.11",
"@angular/core": "^5.2.11",
"@angular/forms": "^5.2.11",
"@angular/http": "^5.2.11",
"@angular/platform-browser": "^5.2.11",
"@angular/platform-browser-dynamic": "^5.2.11",
"@angular/router": "^5.2.11",
"@angular/service-worker": "^5.2.11",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^3.0.1",
"adal-angular": "=1.0.15",
"adal-angular4": "^2.0.13",
"ang-jsoneditor": "^1.8.4",
"angular2-csv": "^0.2.5",
"angular2-qrscanner": "^1.0.7",
"bootstrap": "^3.4.1",
"core-js": "^2.6.10",
"expose-loader": "^0.7.5",
"file-saver": "^2.0.2",
"font-awesome": "^4.7.0",
"jquery": "^3.4.1",
"jsoneditor": "^8.0.0",
"jspdf": "^1.4.1",
"jszip": "^3.2.2",
"moment": "^2.24.0",
"moment-timezone": "^0.5.27",
"ng-click-outside": "^3.2.0",
"ng2-pagination": "^2.0.2",
"ng2-people-picker": "^1.2.0",
"ngx-lightbox": "^1.2.0",
"ngx-pagination": "^3.3.1",
"ngx-popover": "0.0.16",
"ngx-translate-multi-http-loader": "^3.0.0",
"popper.js": "^1.16.0",
"primeng": "^5.2.7",
"rxjs": "^5.5.12",
"xlsx": "^0.13.1",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.2.11",
"@angular/language-service": "^5.2.11",
"@types/jasmine": "^2.8.16",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^6.0.118",
"codelyzer": "^4.5.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.5",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}```
It was working earlier, but after some changes in application it stopped asking for permission.
Can't access camera on android devices.
Any idea?
This angular2-qrscanner works great when running in development via localhost, but when I build and deploy for production I get the following line in the console log:
"QR Scanner init, facing undefined"
followed by error:
"vendor.js:8 ERROR TypeError: Cannot read property 'style' of null
at t.initCanvas..
I am using angular 4 with universal for Server Side Rendering.
I've tried excluding angular2-qrscanner from tree-shaking, tried gating with <div *ngIf="isBrowser"> tags, tried moving the imports from main app.module to the app.module.browser, but none of this seems to work.
Anyone have any ideas?
Hi,
A mere few minutes ago, I downloaded this package but this error was showed.
Another question: inside the 'dist' folder, I didn't see any index.html; how should I run this project at a public server?
Best regards.
Hi!
First of all, thank you for this great library.
After upgrading to v1.0.1 I'm getting errors:
Error: Metadata version mismatch for module C:/my-demo-app/node_modules/angular2-qrscanner/angular2-qrscanner.d.ts, found version 4, expected 3
I think it's because of the use of Angular 5. Is there any way to get it back to Angular 4?
As the variable "supported" was changed to public, but the ngFactories were not regenerated, the aot compilation of dependent apps is failing.
ERROR in node_modules/angular2-qrscanner/qr-scanner.module.d.ts:2:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
This likely means that the library (angular2-qrscanner) which declares NgQrScannerModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
2 export declare class NgQrScannerModule {
Any fast solution please ?
I am using angular2. when I import modules and run ng build then ng serve getting error saying
@angular/core/index"' has no exported member 'Renderer2'
I googled and came to know Renderer2 is in angular4.
any workaround to get this working?
Thanks In advance
I'm using this module for an angular 4 application,
'angular/cli: 1.3.2'
'angular/compiler-cli: 4.3.6 '
The module is working fine unless I do a AOT build, and exactly as a result of AOT build, the build fails with an error "metadata version mismatch for module angular2-qrscanner found version 4, expected 3". Seems like, the module was built with angular 5+ as it introduced the metadata version 4.
Please assist in this scenario or at least suggest the lower version to which I can safely downgrade the module to without breaking my functionality.
npm install [email protected]
installs an empty package. There is no any js file nor dist folder under node_modules/angular2-qrscanner
.
As a workaround, I installed it with URL.
npm install https://github.com/goergch/angular2-qrscanner
Hi, this is not an issue but I don't know other way to ask questions
I'm new on Angular 2, maybe it's a stupid question, but I'm trying to import the 'QrScannerComponent' doing:
import * as qr from 'angular2-qrscanner\src\qrscanner.component'
OR
import * as qr from 'angular2-qrscanner\dist\src\qrscanner.component'
with both, my code doesn't show errors, but when I test in browser, it says that can't find the 'qrscanner.component.js', so I tried importing from 'angular2-qrscanner\src\qrscanner.component.js' and get another Not found error, that would require to update the library.
I think I'm missing something on the importation, but I can't find any suggestion that works.
I hope that make sense, english is not my native language
Thanks
When I installed the
'@angular-devkit/[email protected]'
library, I saw this message.
The AppComponent.html is the same file of the project, unmodified.
Brs.
I'm getting this error below when trying to compile in production mode, using the npm published version (which seems go come from fork?)
ERROR in d:/a/1/s/src/$$_gendir/node_modules/angular2-qrscanner/src/qrscanner.component.ngfactory.ts (62,31): Property 'supported' is private and only accessible within class 'QrScannerComponent'.
I found that I could make this public and get around the issue locally, but if using a build server it's going to need to this property changed in the source.
Hey guys,
Can you give pointers regarding how we use the package ?
I suppose we need to import something ...
Thanks ! :-)
when no code is scanned, but the element is destroyed, it wont stop scanning/ capturing.
The input property "facing" is never used. The facingMode is hardcoded to "environment" in qrscanner.component.ts line 164:
options={'deviceId': {'exact':device.deviceId}, 'facingMode':'environment'} ;
I can adjust width and height via canvasWidth and canvasHeight. I am using it in Chrome Version 61.0.3163.79 (Official Build) (64-bit) and @angular/cli: 1.4.2
Does it work for anyone?
Since the update to Chrome 65 on mobile devices the live view is stuttering and adjusts the focus slowly. Does anyone have the same issue?
So, I get the subscription from onRead
but then the scanner stops and I can't re-initialize it via Viewchild.load()
(it initializes, but it doesn't start the scanner for some reason)
If you have no video device the function "stopScanning" called in ngOnDestroy produces an error at line 44:
this.stream.getTracks()[0].stop();
Testing if this.stream and if this.stream.getTracks() exists should prevent these errors.
I've just added angular2-qrscanner to my project and when I load my site in chrome I get the following error message in debug console:
Uncaught TypeError: Cannot set property 'gUM' of undefined at errror (qrscanner.component.ts:79)
If I change the line 79 in qrscanner.component.ts (and of course in .js) from
this.gUM=false
to
self.gUM=false
then everything works fine.
I try the component but it's seem that something is wrong when try to read variable : "reader.DataByte" in qrcode.js
Tested in :
Desktop ( HP Envy )
Chrome Browser
Application show correctly the image from camera and when QR appear into video it did something.... but it's seem that it is not able to read "reader.DataByte"
i did the following step :
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { QrScannerModule } from 'angular2-qrscanner';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
QrScannerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<!--The whole content below can be removed with the new code.-->
<div style="text-align:center">
<qr-scanner [debug]="true" (onRead)="decodedOutput($event)"></qr-scanner>
</div>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
decodedOutput(Evento) {
console.log('Ho fatto qualcosa ') ;
console.log(Evento) ;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.