|
@@ -77,9 +77,12 @@ export default {
|
|
// height: this.showRecognizeButton ? 300 : 250
|
|
// height: this.showRecognizeButton ? 300 : 250
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
- video.srcObject = stream;
|
|
|
|
- video.play();
|
|
|
|
|
|
+ if (stream) {
|
|
|
|
+ video.srcObject = stream;
|
|
|
|
+ video.play();
|
|
|
|
+ } else {
|
|
|
|
+ this.$Message.error("没有可用的视频流");
|
|
|
|
+ }
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.log(error);
|
|
console.log(error);
|
|
this.$Message.error("无法启用摄像头");
|
|
this.$Message.error("无法启用摄像头");
|
|
@@ -149,7 +152,7 @@ export default {
|
|
async getSnapShot() {
|
|
async getSnapShot() {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
const video = this.$refs.video;
|
|
const video = this.$refs.video;
|
|
- if (video.readyState !== 4) {
|
|
|
|
|
|
+ if (video.readyState !== 4 && video.srcObject.active) {
|
|
this.$Message.error({ content: "摄像头没有正常启用", duration: 5 });
|
|
this.$Message.error({ content: "摄像头没有正常启用", duration: 5 });
|
|
reject("摄像头没有正常启用");
|
|
reject("摄像头没有正常启用");
|
|
this.logout();
|
|
this.logout();
|