New js file for camera.pi plugin

This commit is contained in:
Fabio Manganiello 2020-09-27 02:52:20 +02:00
parent 31f2c5152c
commit 9ad6188b5d

View file

@ -1,52 +1,19 @@
Vue.component('camera-pi', { Vue.component('camera-pi', {
template: '#tmpl-camera-pi', template: '#tmpl-camera-pi',
props: ['config'], mixins: [cameraMixin],
data: function() {
return {
bus: new Vue({}),
streaming: false,
capturing: false,
};
},
methods: { methods: {
startStreaming: function() { startStreaming: function() {
if (this.streaming) this._startStreaming('pi');
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');
}, },
capture: function() { capture: function() {
if (this.capturing) this._capture('pi');
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;
}
}, },
}, },
mounted: function() { mounted: function() {
this.$refs.frame.addEventListener('load', this.onFrameLoaded); this.attrs.resolution = [640, 480];
}, }
}); });