| 19 | * Base class for browser code reader. |
| 20 | */ |
| 21 | export class BrowserCodeReader { |
| 22 | /** |
| 23 | * If navigator is present. |
| 24 | */ |
| 25 | public get hasNavigator() { |
| 26 | return typeof navigator !== 'undefined'; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * If mediaDevices under navigator is supported. |
| 31 | */ |
| 32 | public get isMediaDevicesSuported() { |
| 33 | return this.hasNavigator && !!navigator.mediaDevices; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * If enumerateDevices under navigator is supported. |
| 38 | */ |
| 39 | public get canEnumerateDevices() { |
| 40 | return !!( |
| 41 | this.isMediaDevicesSuported && navigator.mediaDevices.enumerateDevices |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * This will break the loop. |
| 47 | */ |
| 48 | private _stopContinuousDecode = false; |
| 49 | |
| 50 | /** |
| 51 | * This will break the loop. |
| 52 | */ |
| 53 | private _stopAsyncDecode = false; |
| 54 | |
| 55 | /** |
| 56 | * Delay time between decode attempts made by the scanner. |
| 57 | */ |
| 58 | protected _timeBetweenDecodingAttempts: number = 0; |
| 59 | |
| 60 | /** Time between two decoding tries in milli seconds. */ |
| 61 | get timeBetweenDecodingAttempts(): number { |
| 62 | return this._timeBetweenDecodingAttempts; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Change the time span the decoder waits between two decoding tries. |
| 67 | * |
| 68 | * @param {number} millis Time between two decoding tries in milli seconds. |
| 69 | */ |
| 70 | set timeBetweenDecodingAttempts(millis: number) { |
| 71 | this._timeBetweenDecodingAttempts = millis < 0 ? 0 : millis; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * The HTML canvas element, used to draw the video or image's frame for decoding. |
| 76 | */ |
| 77 | protected captureCanvas: HTMLCanvasElement; |
| 78 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected