Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions src/components/StreamBarcodeReader.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<template>
<div class="scanner-container">
<div v-show="!isLoading">
<video poster="data:image/gif,AAAA" ref="scanner"></video>
<div class="overlay-element"></div>
<div class="laser"></div>
</div>
<div class="scanner">
<div class="scanner-ui" v-show="!isLoading">
<button type='button' @click="torchChange(!torch)">Flash</button>
</div>
<div class="scanner-container">
<div v-show="!isLoading">
<video poster="data:image/gif,AAAA" ref="scanner"></video>
<div class="overlay-element"></div>
<div class="laser"></div>
</div>
</div>
</div>
</template>

Expand All @@ -16,6 +21,7 @@ export default {

data() {
return {
torch: false,
isLoading: true,
codeReader: new BrowserMultiFormatReader(),
isMediaStreamAPISupported:
Expand Down Expand Up @@ -44,6 +50,7 @@ export default {

methods: {
start() {
// console.log(this.$refs.scanner)
this.codeReader.decodeFromVideoDevice(
undefined,
this.$refs.scanner,
Expand All @@ -53,6 +60,15 @@ export default {
}
}
);
/* setTimeout(() => { document.getElementsByTagName('video')[0]
.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: true }] }); }, 2000);*/

},
torchChange(value) {
alert(value)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be removed to avoid nag popup during demo

document.getElementsByTagName('video')[0]
.srcObject.getVideoTracks()[0].applyConstraints({ advanced: [{ torch: value }] });
this.torch = value;
}
}
};
Expand Down Expand Up @@ -124,4 +140,4 @@ video {
transform: translateY(75px);
}
}
</style>
</style>