Class: MultiScannerElement

MultiScannerElement()

Barcode scanning web component capable of scanning multiple formats of barcodes.

Constructor

new MultiScannerElement()

Create a MultiScannerElement.
Source:

Members

_$Map

Element Map.
Source:

_image_track_constraints

Get image_track_constraints Extra Image Constraints.
Source:

_supported_constraints

Supported Track Constraints for this browser.
Source:

_template

The default template HTML string.
Source:

_video_track_constraints

Get video_track_constraints Extra Image Constraints.
Source:

cameraId

CameraId for the scanner.
Source:

device

Get device for the scanner.
Source:

device

Set device for the scanner.
Source:

formats

Get formats for the scanner. The scannable types of barcodes.
Source:

formats

Set formats for the scanner. The scannable types of barcodes.
Source:

image_track_constraints

Valid image_track_constraints
Source:

line_args

Get line_args for the scanner.
Source:

line_color

Get line_color for the scanner.
Source:

line_color

Set line_color for the scanner.
Source:

line_join

Get line_join for the scanner.
Source:

line_join

Set line_join for the scanner.
Source:

line_shadow_blur

Get line_shadow_blur for the scanner.
Source:

line_shadow_blur

Set line_shadow_blur for the scanner.
Source:

line_shadow_color

Get line_shadow_color for the scanner.
Source:

line_shadow_color

Set line_shadow_color for the scanner.
Source:

line_width

Get line_width for the scanner.
Source:

line_width

Set line_width for the scanner.
Source:

media_track_constraints

Get media_track_constraints Inital argmuents passed to getUserMedia. Defaults to {video: { facingMode: 'environment'}}
Source:

settings

Settings for the scanner.
Source:

state

Get state for the scanner.
Source:

state

Set state for the scanner.
Source:

stream

Getting _stream.
Source:

stream

Setting new _stream.
Source:

track

Getting _track.
Source:

track

Setting new _track.
Source:

track_capabilities

Getting track_capabilities.
Source:

track_constraints

Getting track_constraints.
Source:

track_settings

Getting track_settings.
Source:

video_track_constraints

Valid video_track_constraints
Source:

videoDevicesPromise

Get videoDevicesPromise available to scan with.
Source:

web_worker

Get web_worker for the scanner.
Source:

web_worker

Set web_worker for the scanner.
Source:

Methods

_constraintAttrUpdate(obj)

Constraint has been updated through the attribute. Sets the private private propterty. Respects supported constraints & track capabilities If a new constraint value is not a part of the supported constraints than the method will return. If the current track_capabilities is set then the new constraint value will be checked to ensure that it valid.
Parameters:
Name Type Description
obj Object An Object
Properties
Name Type Description
c_prop String Property (camelCase) to be updated.
c_attr String Attribute (snakeCase w/ hyphen) that was updated.
new_c String New value of the constraint.
c_type String Type of the constraint.
Source:

_constraintPropUpdate(obj)

Constraint is being updated through the property. Sets the attribute if validation passes Respects supported constraints & track capabilities If a new constraint value is not a part of the supported constraints than the method will return. If the current track_capabilities is set then the new constraint value will be checked to ensure that it valid.
Parameters:
Name Type Description
obj Object An Object
Properties
Name Type Description
c_prop String Property (camelCase) to be updated.
c_attr String Attribute (snakeCase w/ hyphen) that was updated.
new_c String New value of the constraint.
c_type String Type of the constraint.
Source:

_reduce_constraints(obj)

Reduce constraints based on supported constraints & track capabilities If a new constraint value is not a part of the supported constraints than it will not be included in the return value. If the current track_capabilities is set then the new constraint value will be checked to ensure that it valid. Invalid constraints will not be included in the return value.
Parameters:
Name Type Description
obj Object An Object
Properties
Name Type Description
current_constraints Object Constraints already set.
constraints_constant Object Constant constraints ie Video or Image etc.
Source:

applyConstraints()

Applies Constraints to the track/stream.
Source:

attributeChangedCallback(name, oldValue, newValue)

Attributes on this element have changed.
Parameters:
Name Type Description
name string Which attribute has chaned.
oldValue string Previous value of attribute.
newValue string Current value of attribute.
Source:

connectedCallback()

The element has been connected to the DOM.
Source:

disconnectedCallback()

The element has been disconnected from the DOM.
Source:

drawCode(obj)

Draws a box on a canvas given Barcode data. TODO: Determine if a code can be drawn in a single canvas path.
Parameters:
Name Type Description
obj Object An Object
Properties
Name Type Description
canvas HTMLCanvasElement a canvas element.
line_args Object An Object.
Properties
Name Type Description
color string hex color of line, defaults to green.
width int width of line, defaults to 4.
Source:

(async) establishVideoDevices() → {Promise}

Returns the videoDevicesPromise promise. If this promise does not exist already, it calls requestVideoDevices. The this.videoDevicesPromise promise resolves an array of all the attached devices and is shared across all instances Ex: this.__prototype__.videoDevicesPromise
Source:
Returns:
- Resolves an Array of attched video devices.
Type
Promise

guid() → {string}

Create a GUID/UUID string. Globally/Universally Unique ID.
Source:
Returns:
String representing a UUID.
Type
string

onCanPlay()

When camera is ready.
Source:

(async) pause()

Pause the Scanner.
Source:

processNonWebWorker()

Processes ImageData checking for Barcodes. This method is synchronous and does not use a WebWorker.
Source:

(async) processVideoStream() → {function}

Process the canvas image for Barcodes. Will run every animation frame refresh.
Source:
Returns:
- Used inside a requestAnimationFrame call.
Type
function

processWebWorker()

Processes ImageData checking for Barcodes. This method uses a WebWorker. WebWorker is shared between all MultiScannerElements
Source:

(async) requestVideoDevices() → {Promise}

Queries the 'Camera' browser permissions checking if it has been previously granted. Preps user with an alert before prompting user to allow access for the 'Camera' browser permission if not granted. Uses getUserMedia & enumerateDevices to get attached hardware and sort them by 'videoinput' type.
Source:
Returns:
- Resolves an Array of attched video devices.
Type
Promise

(async) restart()

Stop & Start Scanner.
Source:

(async) start()

Start the Scanner.
Source:

(async) stop()

Stop the Scanner.
Source:

(async) stopAll()

Stop all of the Cameras.
Source:

template()

Sets shadow DOM to template HTML string.
Source: