Much better camera support for FKB

This commit is contained in:
2021-07-11 20:58:19 +00:00
parent 87e939c6cb
commit 2ba8977118
7 changed files with 33 additions and 8 deletions

View File

@@ -28,9 +28,15 @@ export const BrowserModCameraMixin = (C) =>
this._camera_framerate = 2;
window.addEventListener("click", () => this._video.play(), {
once: true,
});
window.addEventListener(
"click",
() => {
if (this._video.ended || this._video.paused) this._video.play();
},
{
once: true,
}
);
}
update_camera() {

View File

@@ -66,12 +66,27 @@ export const FullyKioskMixin = (C) =>
});
}
startCamera() {
if (this._fullyCameraTimer !== undefined) return;
this._fullyCameraTimer = window.setInterval(() => {
this.sendUpdate({
camera: window.fully.getCamshotJpgBase64(),
});
}, 200);
}
stopCamera() {
window.clearInterval(this._fullyCameraTimer);
this._fullyCameraTimer = undefined;
}
fullyMotionTriggered() {
if (this._keepingAlive) return;
this._fullyMotion = true;
this.startCamera();
clearTimeout(this._motionTimeout);
this._motionTimeout = setTimeout(() => {
this._fullyMotion = false;
this.stopCamera();
this.fully_update();
}, 5000);
this.fully_update();

View File

@@ -129,7 +129,7 @@ class BrowserMod extends ext(BrowserModConnection, [
if (msg.name) {
this.entity_id = msg.name.toLowerCase();
}
if (msg.camera) {
if (msg.camera && !this.isFully) {
this.setup_camera();
}
this.config = { ...this.config, ...msg };