cordova-plugin-scanbot-sdk
Advanced tools
Comparing version 4.1.0-alpha3 to 4.1.0-beta1
@@ -29,13 +29,14 @@ | ||
this.video.style.objectFit = "cover"; | ||
container.appendChild(this.video); | ||
// Hacks for Mobile Safari | ||
this.video.setAttribute("playsinline", true); | ||
// this.video.setAttribute("controls", true); | ||
// TODO: Safari does, but WKWebView does not allow access to getUserMedia | ||
// https://stackoverflow.com/questions/43916436/enable-camera-and-mic-access-in-wkwebview | ||
const constraints = { video: { facingMode: "environment" } }; | ||
container.appendChild(this.video); | ||
let stream; | ||
if (this.isiOS()) { | ||
// @ts-ignore | ||
stream = await cordova.plugins.iosrtc.getUserMedia(constraints); | ||
} else { | ||
stream = await navigator.mediaDevices.getUserMedia(constraints); | ||
} | ||
const constraints = { video: { facingMode: "environment" } }; | ||
const stream = await navigator.mediaDevices.getUserMedia(constraints); | ||
// @ts-ignore | ||
@@ -92,4 +93,6 @@ await new Promise(resolve => { | ||
// getImageData() extracts a too small area | ||
const width = this.video.width + 2 * this.container.offsetLeft; | ||
const height = this.video.height + 2 * this.container.offsetTop; | ||
// const width = this.video.width + 4 * this.container.offsetLeft; | ||
// const height = this.video.height + 2 * this.container.offsetTop; | ||
const width = this.container.offsetWidth * 1.5; | ||
const height = this.container.offsetHeight * 1.5; | ||
const x = this.video.videoWidth / 2 - width / 2; | ||
@@ -106,4 +109,11 @@ const y = this.video.videoHeight / 2 - height / 2; | ||
const data = this.createImageData(this.canvasContext, this.video); | ||
const octet = await this.Uint8ToStringViaReader(new Uint8Array(data.data)); | ||
let imageData; | ||
if (this.isiOS()) { | ||
imageData = data.data.buffer; | ||
} else { | ||
const octet = await this.Uint8ToStringViaReader(new Uint8Array(data.data)); | ||
imageData = octet; | ||
} | ||
// Uncomment for web debugging | ||
@@ -120,3 +130,3 @@ // requestAnimationFrame(() => this.sendImageData(result)); | ||
requestAnimationFrame(() => this.sendImageData(result)); | ||
}, "ScanbotSdk", "detectBarcodesFromBytes", [ data.width, data.height, octet ]); | ||
}, "ScanbotSdk", "detectBarcodesFromBytes", [ data.width, data.height, imageData ]); | ||
} | ||
@@ -132,2 +142,7 @@ | ||
} | ||
private isiOS(): boolean { | ||
// @ts-ignore | ||
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; | ||
} | ||
} |
@@ -754,2 +754,3 @@ export interface DocumentScannerConfiguration | ||
cleanup(): Promise<GenericResult>; | ||
requestCameraPermission(): Promise<GenericResult>; | ||
} | ||
@@ -756,0 +757,0 @@ |
{ | ||
"name": "cordova-plugin-scanbot-sdk", | ||
"version": "4.1.0-alpha3", | ||
"version": "4.1.0-beta1", | ||
"description": "Cordova Plugin for Scanbot SDK", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -69,3 +69,4 @@ /* | ||
cleanup: makeCaller("cleanup") | ||
cleanup: makeCaller("cleanup"), | ||
requestCameraPermission: makeCaller("requestCameraPermission") | ||
}; | ||
@@ -72,0 +73,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
367558442
3547