|
@@ -3,7 +3,7 @@
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
|
|
- <title></title>
|
|
|
+ <title>视频认证</title>
|
|
|
<style>
|
|
|
body {
|
|
|
margin: 0;
|
|
@@ -131,7 +131,7 @@
|
|
|
</div>
|
|
|
|
|
|
|
|
|
- <!-- <video ref="videob" controls="" name="media" v-show="!showVideo" width="100%" height="400"></video> -->
|
|
|
+ <video ref="videob" controls="" name="media" v-show="!showVideo" width="100%" height="400"></video>
|
|
|
</div>
|
|
|
|
|
|
|
|
@@ -175,7 +175,7 @@
|
|
|
const policyText = {
|
|
|
"expiration": srcT, //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
|
|
|
"conditions": [
|
|
|
- ["content-length-range", 0, 5 * 1024 * 1024] // 设置上传文件的大小限制,5mb
|
|
|
+ ["content-length-range", 0, 100 * 1024 * 1024] // 设置上传文件的大小限制,5mb
|
|
|
]
|
|
|
};
|
|
|
|
|
@@ -194,22 +194,19 @@
|
|
|
// console.log(signature);
|
|
|
return signature;
|
|
|
},
|
|
|
- uploadFile() {
|
|
|
+ uploadFile(file) {
|
|
|
var formdata = new FormData()
|
|
|
const policyBase64 = this.getPolicyBase64();
|
|
|
- console.log("policyBase64-----------------------")
|
|
|
- console.log(policyBase64)
|
|
|
const signature = this.getSignature(policyBase64); //获取签名
|
|
|
- console.log("signatur--------------------------------------e")
|
|
|
- console.log(signature)
|
|
|
- formdata.append("key", 'appData/' + new Date().getTime() + Math.floor(Math.random() * 150) +
|
|
|
- '.png')
|
|
|
+ formdata.append("key", 'appData/video' + new Date().getTime() + Math.floor(Math.random() * 150) +
|
|
|
+ '.mp4')
|
|
|
formdata.append("policy", policyBase64)
|
|
|
formdata.append("OSSAccessKeyId", 'LTAI4G9c14PgKvM23WZ9zrpc')
|
|
|
// E9996KCDUh5wSzsJjHzqaq/FmHk=
|
|
|
// formdata.append("signature", 'E9996KCDUh5wSzsJjHzqaq/FmHk=')
|
|
|
formdata.append("signature", signature)
|
|
|
formdata.append("success_action_status", '200')
|
|
|
+ formdata.append("file",file)
|
|
|
$.ajax({
|
|
|
type: "POST",
|
|
|
data: formdata,
|
|
@@ -322,8 +319,35 @@
|
|
|
}, 1000)
|
|
|
}
|
|
|
},
|
|
|
+ dataURLtoBlob(dataurl) {
|
|
|
+
|
|
|
+ var arr = dataurl.split(","),
|
|
|
+
|
|
|
+ mime = arr[0].match(/:(.*?);/)[1],
|
|
|
+
|
|
|
+ bstr = atob(arr[1]),
|
|
|
+
|
|
|
+ n = bstr.length,
|
|
|
+
|
|
|
+ u8arr = new Uint8Array(n);
|
|
|
+
|
|
|
+ while (n--) {
|
|
|
+
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.blobToFile(new Blob([u8arr], { type: mime }), { type: mime });
|
|
|
+
|
|
|
+ },
|
|
|
+ blobToFile(theBlob, type) {
|
|
|
+ theBlob.lastModifiedDate = new Date();
|
|
|
+ return new File([theBlob], `${new Date().getTime()}.mp4`, type);
|
|
|
+
|
|
|
+ },
|
|
|
// 保存录制视频
|
|
|
saveVideo() {
|
|
|
+ let that = this
|
|
|
if (this.isAlreadyRecord) {
|
|
|
this.countTimer && clearTimeout(this.countTimer)
|
|
|
this.showVideo = false
|
|
@@ -335,24 +359,21 @@
|
|
|
}
|
|
|
this.mediaRecorder.stop()
|
|
|
setTimeout(() => {
|
|
|
+ console.log("this.recordedBlobs-------------------------")
|
|
|
var blob = new Blob(this.recordedBlobs, {
|
|
|
type: 'video/mp4'
|
|
|
})
|
|
|
-
|
|
|
- // console.log(blob)
|
|
|
this.isAlreadyRecord = false
|
|
|
this.MediaStreamTrack && this.MediaStreamTrack.stop()
|
|
|
var reader = new FileReader();
|
|
|
- reader.readAsDataURL(blob, 'utf-8')
|
|
|
- reader.onload = () => {
|
|
|
-
|
|
|
- console.log('11111111111111111')
|
|
|
- console.log(reader.result); // base64格式
|
|
|
- // this.$refs.videob.src = reader.result
|
|
|
- this.uploadFile(blob)
|
|
|
-
|
|
|
- console.log(reader)
|
|
|
-
|
|
|
+ reader.readAsDataURL(blob)
|
|
|
+ reader.onload = (e) => {
|
|
|
+ this.$refs.videob.src = reader.result
|
|
|
+
|
|
|
+
|
|
|
+ let a = this.dataURLtoBlob(reader.result)
|
|
|
+ console.log(a)
|
|
|
+ this.uploadFile(a)
|
|
|
}
|
|
|
}, 1000)
|
|
|
} else {
|