From 9ad6188b5da3c909007316b6e2a861d3a22cd4c5 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 27 Sep 2020 02:52:20 +0200 Subject: [PATCH] New js file for camera.pi plugin --- .../http/static/js/plugins/camera.pi/index.js | 43 +++---------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/platypush/backend/http/static/js/plugins/camera.pi/index.js b/platypush/backend/http/static/js/plugins/camera.pi/index.js index 8b419339..d7f4a9c0 100644 --- a/platypush/backend/http/static/js/plugins/camera.pi/index.js +++ b/platypush/backend/http/static/js/plugins/camera.pi/index.js @@ -1,52 +1,19 @@ Vue.component('camera-pi', { template: '#tmpl-camera-pi', - props: ['config'], - - data: function() { - return { - bus: new Vue({}), - streaming: false, - capturing: false, - }; - }, + mixins: [cameraMixin], methods: { startStreaming: function() { - if (this.streaming) - return; - - this.streaming = true; - this.capturing = false; - this.$refs.frame.setAttribute('src', '/camera/pi/stream'); - }, - - stopStreaming: function() { - if (!this.streaming) - return; - - this.streaming = false; - this.capturing = false; - this.$refs.frame.removeAttribute('src'); + this._startStreaming('pi'); }, capture: function() { - if (this.capturing) - return; - - this.streaming = false; - this.capturing = true; - this.$refs.frame.setAttribute('src', '/camera/pi/frame?t=' + (new Date()).getTime()); - }, - - onFrameLoaded: function(event) { - if (this.capturing) { - this.capturing = false; - } + this._capture('pi'); }, }, mounted: function() { - this.$refs.frame.addEventListener('load', this.onFrameLoaded); - }, + this.attrs.resolution = [640, 480]; + } });