forked from platypush/platypush
New js file for camera.pi plugin
This commit is contained in:
parent
31f2c5152c
commit
9ad6188b5d
1 changed files with 5 additions and 38 deletions
|
@ -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];
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue