fix(capture): enable/disable capture button

This commit is contained in:
wryk 2019-03-15 20:43:34 +01:00
parent 81d0919f2a
commit bcf1dc9b52
2 changed files with 9 additions and 2 deletions

View file

@ -40,6 +40,8 @@ export default new Vuex.Store({
if (state.mediaStream) {
state.mediaStream.getTracks().forEach(track => track.stop())
}
state.mediaStream = null
},
inverseFacingMode (store) {
store.capturing.shouldFaceUser = !store.capturing.shouldFaceUser

View file

@ -6,10 +6,10 @@
<capture-options v-else></capture-options>
<div class="preview">
<video ref="preview" class="preview-visual" preload="yes" :srcObject.prop="mediaStream" autoplay muted playsinline webkit-playsinline></video>
<video ref="preview" class="preview-visual" preload="yes" autoplay muted playsinline webkit-playsinline></video>
</div>
<button class="capture-btn" :class="{ 'capture-btn--capturing': capturing.status }" @click.prevent="startCapture">Capture</button>
<button class="capture-btn" :class="{ 'capture-btn--capturing': capturing.status }" @click.prevent="startCapture" :disabled="!mediaStream">Capture</button>
<encoding-overlay v-if="encoding.status"></encoding-overlay>
</div>
@ -44,6 +44,11 @@ export default {
this.$store.dispatch('capture')
}
},
watch: {
mediaStream: function (mediaStream) {
this.$refs.preview.srcObject = mediaStream
}
},
mounted: function () {
window.objectFitPolyfill(this.$refs.preview)
document.body.classList.add('capture-body')