<template>
<view class="rootView">
<video ref="video" autoplay playsinline muted id="video" style="width: 100px; height: 100px;"></video>
<button v-on:click="startRecording">开启摄像头</button>
<button v-on:click="stopRecording">关闭摄像头</button>
</view>
</template>
<script>
export default {
name: 'indexPage',
data: function() {
return {
mediaRecorder: null,
videoStream: '',
videoElement: null,
chunks: [],
}
},
onLoad() {
},
mounted() {
},
methods: {
async startRecording() {
try {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
if(this.$refs.video) {
this.$refs.video.srcObject = stream;
}
} catch (error) {
console.error('Error accessing media devices.', error);
}
},
stopRecording() {
},
stopCamera() {
},
test() {
uni.chooseVideo({
sourceType: ['camera', 'album'],
success: function (res) {
self.src = res.tempFilePath;
}
});
}
}
}
</script>
<style>
</style>
1 个回复
DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信
权限申请了吗,普通的 h5 页面展示是否正常?是在浏览器打开还是微信打开?