Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceG committed Sep 27, 2019
1 parent 1169751 commit 424f249
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 102 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ npm run dev
| -------------- | -------- | ----------------------------------------------------------------------- |
| capture | void | Capture the current image through the webcam as base64 encoded string |
| changeCamera | deviceId | change the currently selected camera. Must pass in the device ID |
| start | void | Programatically Start the camera after stopping it (relies on deviceId prop passed to the component) |
| stop | void | Programatically stop the camera |
| start | void | Programmatically Start the camera after stopping it (relies on deviceId prop passed to the component) |
| stop | void | Programmatically stop the camera |
| pause | void | Programmatically pause the camera |
| resume | void | Programmatically resume the camera after it was paused |

## Contributing

Expand Down
194 changes: 96 additions & 98 deletions demo/src/main.vue
Original file line number Diff line number Diff line change
@@ -1,114 +1,112 @@
<template>
<div class="container">
<div class="row">
<div class="col-md-6">
<h2>Current Camera</h2>
<code v-if="device">{{ device.label }}</code>
<div class="border">
<vue-web-cam ref="webcam"
:device-id="deviceId"
width="100%"
@started="onStarted"
@stopped="onStopped"
@error="onError"
@cameras="onCameras"
@camera-change="onCameraChange" />
</div>

<div class="container">
<div class="row">
<div class="col-md-12">
<select v-model="camera">
<option>-- Select Device --</option>
<option v-for="device in devices"
:key="device.deviceId"
:value="device.deviceId">{{ device.label }}</option>
</select>
</div>
<div class="col-md-12">
<button type="button"
class="btn btn-primary"
@click="onCapture">Capture Photo</button>
<button type="button"
class="btn btn-danger"
@click="onStop">Stop Camera</button>
<button type="button"
class="btn btn-success"
@click="onStart">Start Camera</button>
</div>
<div class="col-md-6">
<h2>Current Camera</h2>
<code v-if="device">{{ device.label }}</code>
<div class="border">
<vue-web-cam
ref="webcam"
:device-id="deviceId"
width="100%"
@started="onStarted"
@stopped="onStopped"
@error="onError"
@cameras="onCameras"
@camera-change="onCameraChange"
/>
</div>

<div class="row">
<div class="col-md-12">
<select v-model="camera">
<option>-- Select Device --</option>
<option
v-for="device in devices"
:key="device.deviceId"
:value="device.deviceId"
>{{ device.label }}</option>
</select>
</div>
<div class="col-md-12">
<button type="button" class="btn btn-primary" @click="onCapture">Capture Photo</button>
<button type="button" class="btn btn-danger" @click="onStop">Stop Camera</button>
<button type="button" class="btn btn-success" @click="onStart">Start Camera</button>
</div>
</div>
</div>
<div class="col-md-6">
<h2>Captured Image</h2>
<figure class="figure">
<img :src="img" class="img-responsive" />
</figure>
</div>
</div>
</div>
<div class="col-md-6">
<h2>Captured Image</h2>
<figure class="figure">
<img :src="img" class="img-responsive" >
</figure>
</div>
</div>
</div>
</template>

<script>
import { WebCam } from "vue-web-cam";
import { WebCam } from "../../src";
export default {
name: "App",
components: {
"vue-web-cam": WebCam
},
data() {
return {
img: null,
camera: null,
deviceId: null,
devices: []
};
},
computed: {
device: function() {
return this.devices.find(n => n.deviceId === this.deviceId);
}
},
watch: {
camera: function(id) {
this.deviceId = id;
},
devices: function() {
// Once we have a list select the first one
const [first, ...tail] = this.devices;
if (first) {
this.camera = first.deviceId;
this.deviceId = first.deviceId;
}
}
},
methods: {
onCapture() {
this.img = this.$refs.webcam.capture();
},
onStarted(stream) {
console.log("On Started Event", stream);
},
onStopped(stream) {
console.log("On Stopped Event", stream);
},
onStop() {
this.$refs.webcam.stop();
name: "App",
components: {
"vue-web-cam": WebCam
},
onStart() {
this.$refs.webcam.start();
data() {
return {
img: null,
camera: null,
deviceId: null,
devices: []
};
},
onError(error) {
console.log("On Error Event", error);
computed: {
device: function() {
return this.devices.find(n => n.deviceId === this.deviceId);
}
},
onCameras(cameras) {
this.devices = cameras;
console.log("On Cameras Event", cameras);
watch: {
camera: function(id) {
this.deviceId = id;
},
devices: function() {
// Once we have a list select the first one
const [first, ...tail] = this.devices;
if (first) {
this.camera = first.deviceId;
this.deviceId = first.deviceId;
}
}
},
onCameraChange(deviceId) {
this.deviceId = deviceId;
this.camera = deviceId;
console.log("On Camera Change Event", deviceId);
methods: {
onCapture() {
this.img = this.$refs.webcam.capture();
},
onStarted(stream) {
console.log("On Started Event", stream);
},
onStopped(stream) {
console.log("On Stopped Event", stream);
},
onStop() {
this.$refs.webcam.stop();
},
onStart() {
this.$refs.webcam.start();
},
onError(error) {
console.log("On Error Event", error);
},
onCameras(cameras) {
this.devices = cameras;
console.log("On Cameras Event", cameras);
},
onCameraChange(deviceId) {
this.deviceId = deviceId;
this.camera = deviceId;
console.log("On Camera Change Event", deviceId);
}
}
}
};
</script>
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-web-cam",
"version": "1.6.0",
"version": "1.7.0",
"description": "Webcam component for Vuejs applications",
"main": "dist/index.js",
"author": {
Expand Down

0 comments on commit 424f249

Please sign in to comment.