Skip to content

Commit 0e1ce65

Browse files
committed
update samples and readme;
1 parent b1868a7 commit 0e1ce65

File tree

3 files changed

+46
-15
lines changed

3 files changed

+46
-15
lines changed

1.hello-world/11.read-video-requirejs.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,25 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
3838
*/
3939

4040
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected]/dist/";
41-
let pScanner = null;
4241
(async function() {
4342
try {
44-
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
43+
const scanner = await BarcodeScanner.createInstance();
44+
/*
45+
* 'onFrameRead' is triggered after the library finishes reading a frame.
46+
* There can be one or multiple barcodes on each frame.
47+
*/
4548
scanner.onFrameRead = results => {
4649
console.log("Barcodes on one frame:");
4750
for (let result of results) {
4851
const format = result.barcodeFormatString;
4952
console.log(format + ": " + result.barcodeText);
5053
}
5154
};
55+
/*
56+
* onUnduplicatdRead is triggered only when a 'new' barcode is found.
57+
* The amount of time that the library 'remembers' a barcode is defined by
58+
* "duplicateForgetTime" in "ScanSettings". By default it is set to 3000 ms.
59+
*/
5260
scanner.onUniqueRead = (txt, result) => {
5361
alert(txt);
5462
console.log("Unique Code Found: ", result);

1.hello-world/12.read-video-es6.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
3636

3737
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected]/dist/";
3838

39-
let pScanner = null;
4039
(async () => {
4140
try {
42-
const scanner = await (pScanner = pScanner || BarcodeScanner.createInstance());
41+
const scanner = await BarcodeScanner.createInstance();
4342
/*
4443
* 'onFrameRead' is triggered after the library finishes reading a frame.
4544
* There can be one or multiple barcodes on each frame.

1.hello-world/README.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Let's break down each of the samples
88

99
## Hello World - Read Barcodes via Video
1010

11-
In this sample, you will find the basic lines of code ncessary to initialize the SDK and set it up.
11+
In this sample, you will find the basic lines of code necessary to initialize the SDK and set it up.
1212

1313
Let's quickly break down the methods used in order:
1414

@@ -30,47 +30,71 @@ In this sample, a event listener is set up so that the SDK decodes any image tha
3030

3131
## Hello World in Angular
3232

33-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-angular.html).
33+
Read more in the README under "3.read-video-angular".
3434

3535
## Hello World in React
3636

37-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-reactjs.html).
37+
Read more in the README under "4.read-video-react".
38+
39+
## Hello World in React with Hooks
40+
41+
Read more in the README under "13.read-video-react-hook".
3842

3943
## Hello World in Vue 2
4044

41-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-vuejs.html).
45+
Read more in the README under "5.read-video-vue".
4246

4347
## Hello World in Vue 3
4448

45-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-vuejsv3.html).
49+
Read more in the README under "6.read-video-vue3".
4650

4751
## Hello World in Next.js
4852

49-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-nextjs.html).
53+
Read more in the README under "7.read-video-nextjs".
5054

5155
## Hello World in NuxtJS
5256

53-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-nuxtjs.html).
57+
Read more in the README under "8.read-video-nuxtjs".
5458

5559
## Hello World in Electron
5660

57-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-electron.html).
61+
Read more in the README under "9.read-video-electron".
5862

5963
## Hello World in PWA
6064

61-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-pwa.html).
65+
Read more in the README under "10.read-video-pwa".
6266

6367
## Hello World with RequireJS
6468

65-
Read more on the sample [here](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-requirejs.html).
69+
This sample shows how to use the SDK in a web page based on RequireJS.
70+
71+
Let's quickly break down the methods used in order:
72+
73+
* `license`: This property specifies a license key. Read more on Specify the license.
74+
* `createInstance()`: This method creates a `BarcodeScanner` object. This object can read barcodes directly from a video input with the help of its interactive UI (hidden by default) and the MediaDevices interface.
75+
* `onFrameRead`: This event is triggered every time the SDK finishes scanning a video frame. The `results` object contains all the barcode results that the SDK have found on this frame. In this example, we print the results to the browser console.
76+
* `onUniqueRead`: This event is triggered when the SDK finds a new barcode, which is not a duplicate among multiple frames. `txt` holds the barcode text value while `result` is an object that holds details of the barcode. In this example, an alert will be displayed for this new barcode.
77+
* `show()`: This method brings up the built-in UI of the `BarcodeScanner` object and starts scanning
78+
79+
In fact, `onFrameRead` and `onUniqueRead` do not have to both be defined in the code. `onUniqueRead` is the more used one between the two as it is triggered when a new barcode is found rather than on every frame.
6680

6781
## Hello World with ES6
6882

6983
This sample shows how to use the SDK in a web page based on ES6 (also known as ECMAScript 2015 or ECMAScript 6).
7084

85+
Let's quickly break down the methods used in order:
86+
87+
* `license`: This property specifies a license key. Read more on Specify the license.
88+
* `createInstance()`: This method creates a `BarcodeScanner` object. This object can read barcodes directly from a video input with the help of its interactive UI (hidden by default) and the MediaDevices interface.
89+
* `onFrameRead`: This event is triggered every time the SDK finishes scanning a video frame. The `results` object contains all the barcode results that the SDK have found on this frame. In this example, we print the results to the browser console.
90+
* `onUniqueRead`: This event is triggered when the SDK finds a new barcode, which is not a duplicate among multiple frames. `txt` holds the barcode text value while `result` is an object that holds details of the barcode. In this example, an alert will be displayed for this new barcode.
91+
* `show()`: This method brings up the built-in UI of the `BarcodeScanner` object and starts scanning
92+
93+
In fact, `onFrameRead` and `onUniqueRead` do not have to both be defined in the code. `onUniqueRead` is the more used one between the two as it is triggered when a new barcode is found rather than on every frame.
94+
7195
## Hello World with WebView
7296

73-
This sample shows how to use Mobile SDK in web pages through webview, you can read more in moblie samples repository:[Android](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/main/android/JavaScript/WebViewBarcodeScanning)/[iOS](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/main/ios/JavaScript/WebViewBarcodeScanning).
97+
Read more in the README under "14.read-video-webview".
7498

7599
## Support
76100

0 commit comments

Comments
 (0)