This shows you the differences between two versions of the page.
plugins:barcode_reader [2015/03/26 10:51] octazid created |
plugins:barcode_reader [2015/03/26 18:53] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== BarcodeReader-Plugin ====== | ||
- | |||
- | :!:\\ | ||
- | //(You must buy and install the plugin over the plugin section within DroidScript)// | ||
- | |||
- | //Taken from the official DroidScript documentation// | ||
- | |||
- | The BarcodeReader plugin can be used to add barcode reading capabilities to your DroidScript apps. One and two dimensional barcodes (including QR Codes) can be read from a CameraView or Image control. | ||
- | |||
- | In order to use BarcodeReader, | ||
- | < | ||
- | |||
- | Then you can create an instance of the plugin object when you need it like this: | ||
- | < | ||
- | |||
- | Reading barcodes is a simple case of calling the **Decode** method, passing either an Image control or CameraView. | ||
- | < | ||
- | |||
- | Note that when decoding from a CameraView, the **" | ||
- | |||
- | The following example periodically attempts to decode a barcode from the camera and displays the decoded content when it finds one: | ||
- | |||
- | ==== Example - Reading from a CameraView ==== | ||
- | <code javascript> | ||
- | app.LoadPlugin( " | ||
- | |||
- | function OnStart() | ||
- | { | ||
- | app.SetOrientation( " | ||
- | |||
- | lay = app.CreateLayout( " | ||
- | |||
- | reader = app.CreateObject( " | ||
- | |||
- | cam = app.CreateCameraView( 0.8, 1, "VGA, UseYUV" | ||
- | cam.SetOnReady( cam_OnReady ); | ||
- | lay.AddChild( cam ); | ||
- | |||
- | app.AddLayout( lay ); | ||
- | } | ||
- | |||
- | function cam_OnReady() | ||
- | { | ||
- | cam.StartPreview(); | ||
- | cam.SetFocusMode( " | ||
- | DecodeFromCamera(); | ||
- | } | ||
- | |||
- | function DecodeFromCamera() | ||
- | { | ||
- | var result = reader.Decode( cam ); | ||
- | |||
- | if( result != null ) | ||
- | { | ||
- | app.ShowPopup( result.barcodeType + ": " + result.content ); | ||
- | } | ||
- | |||
- | setTimeout( DecodeFromCamera, | ||
- | } | ||
- | </ | ||
- | |||
- | If a barcode is successfully decoded, the Decode method will return a result object. The result object contains the following properties: | ||
- | |||
- | ^Property^ Description^ | ||
- | |barcodeType | ||
- | |contentType | ||
- | |content | ||
- | |raw |Contains the barcode content in it's original form. In some cases this will be the same as the content property, but if the contentType is ADDRESSBOOK for example, the raw property will contain the vCard or meCard contact data.| | ||
- | |||
- | By default, when Decode is called, the plugin will attempt to detect all types of barcodes defined in the **Supported Barcodes** section. The **SetBarcodeTypes** method allows you to specify which barcode types you are interested in. The required barcode types can be passed to SetBarcodeTypes as a comma separated string. For example, to decode only QR Code and Data Matrix types: | ||
- | |||
- | < | ||
- | |||
- | ==== Supported Barcodes ==== | ||
- | |||
- | The following table lists the supported barcode types, represented by the **barcodeType** property of the result object returned by the Decode method: | ||
- | ^Barcode Type^ Description^ | ||
- | |CODABAR |[[http:// | ||
- | |CODE 128 |[[http:// | ||
- | |CODE 39 |[[http:// | ||
- | |CODE 93 |[[http:// | ||
- | |DATA MATRIX |[[http:// | ||
- | |EAN 13 |European Article Number (Aka International Article Number). [[http:// | ||
- | |EAN 8 |European Article Number. [[http:// | ||
- | |ITF |Interleaved 2 of 5. [[http:// | ||
- | |QR CODE |Quick Response Code. [[http:// | ||
- | |RSS |Reduced Space Symbology (Aka GS1 DataBar). [[http:// | ||
- | |UPC |Universal Product Code. [[http:// | ||
- | |||
- | ==== Content Types ==== | ||
- | |||
- | The following table lists the possible values for the **contentType** property of the result object returned by the Decode method: | ||
- | |||
- | ^Content Type^ Description^ | ||
- | |ADDRESSBOOK |Contact Information| | ||
- | |CALENDAR |Calendar Event| | ||
- | |EMAIL ADDRESS |Email Address| | ||
- | |GEO |Geo Location| | ||
- | |ISBN |International Standard Book Number| | ||
- | |PRODUCT |Product Code| | ||
- | |SMS |SMS Message| | ||
- | |TEL |Telephone Number| | ||
- | |TEXT |Plain Text| | ||
- | |URI |URI| | ||
- | |VIN |Vehicle Identification Number| | ||
- | |WIFI |Wifi Network Information| | ||
- | |||
- | ===== License ===== | ||
- | |||
- | The BarcodeReader plugin uses the [[https:// | ||
- | |||
- | ===== Sample App ===== | ||
- | |||
- | Below is an sample BarcodeReader App, which includes the option to use the flash while scanning for barcodes: | ||
- | |||
- | <code javascript> | ||
- | |||
- | </ | ||