askbot-dragon 0.7.20 → 0.7.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -82,7 +82,7 @@ function ossFileUrl(ossConfig, path, cname) {
|
|
|
82
82
|
function uploadImageByBase64(ossConfig,blob) {
|
|
83
83
|
let ossClient = new OSS(ossConfig);
|
|
84
84
|
|
|
85
|
-
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt
|
|
85
|
+
// object-key可以自定义为文件名(例如file.txt)或目录(例如abc/test/file.txt)的形 式,实现将文件上传至当前Bucket或Bucket下的指定目录。
|
|
86
86
|
let objectKey = pathGenerate(new Date().getTime());
|
|
87
87
|
let result = ossClient.put(objectKey, blob);
|
|
88
88
|
console.debug(result);
|
|
@@ -15,10 +15,13 @@
|
|
|
15
15
|
:raw-controls="true"
|
|
16
16
|
x5-video-player-type="h5-page"
|
|
17
17
|
style="object-fit: contain;width: calc(100vw - 139px);height: 160px;background-color: black;border-radius: 25px;max-width: 230px;padding-left: 10px"
|
|
18
|
+
preload
|
|
19
|
+
:poster="videoSrc+'?spm=qipa250&x-oss-process=video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast'"
|
|
18
20
|
class="video-player vjs-custom-skin"
|
|
19
21
|
:id="msg.keyId+'key'">
|
|
20
22
|
<source :src="videoSrc"/>
|
|
21
23
|
</video>
|
|
24
|
+
<div id="output"></div>
|
|
22
25
|
</div>
|
|
23
26
|
</template>
|
|
24
27
|
<script>
|
|
@@ -30,14 +33,7 @@
|
|
|
30
33
|
data() {
|
|
31
34
|
return {
|
|
32
35
|
videoSrc:'',
|
|
33
|
-
|
|
34
|
-
region: "oss-cn-zhangjiakou",
|
|
35
|
-
//云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
|
|
36
|
-
accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
|
|
37
|
-
accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
|
|
38
|
-
// stsToken: '<Your securityToken(STS)>',
|
|
39
|
-
bucket: "guoranopen-zjk",
|
|
40
|
-
}
|
|
36
|
+
poster:''
|
|
41
37
|
}
|
|
42
38
|
},
|
|
43
39
|
watch: {
|
|
@@ -56,19 +52,20 @@
|
|
|
56
52
|
mounted() {
|
|
57
53
|
this.$nextTick(()=>{
|
|
58
54
|
this.videoSrc = this.url ? this.url : this.localUrl
|
|
59
|
-
this.
|
|
60
|
-
|
|
55
|
+
this.poster = this.videoSrc+'?spm=qipa250&x-oss-process=video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast'
|
|
56
|
+
console.debug('poster',this.poster)
|
|
61
57
|
})
|
|
62
58
|
|
|
63
59
|
},
|
|
64
60
|
methods:{
|
|
65
61
|
getImage(){
|
|
66
62
|
let that = this
|
|
67
|
-
var video;
|
|
63
|
+
var video,output;
|
|
68
64
|
var scale = 0.8;
|
|
69
65
|
|
|
70
66
|
var initialize = function() {
|
|
71
67
|
let id = that.msg.keyId+'key'
|
|
68
|
+
output = document.getElementById("output");
|
|
72
69
|
video = document.getElementById(id);
|
|
73
70
|
video.addEventListener('loadeddata',captureImage);
|
|
74
71
|
};
|
|
@@ -79,15 +76,23 @@
|
|
|
79
76
|
canvas.height = video.videoHeight * scale;
|
|
80
77
|
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
81
78
|
/*var img = document.createElement("img");
|
|
82
|
-
img.crossOrigin = 'anonymous'
|
|
83
|
-
|
|
79
|
+
img.crossOrigin = 'anonymous'
|
|
80
|
+
img.src = canvas.toDataURL("image/png");*/
|
|
81
|
+
let reg = /\.(png|jpg|gif)$/
|
|
82
|
+
console.debug('img.src',output)
|
|
84
83
|
let base64 = canvas.toDataURL("image/png")
|
|
85
84
|
let blob = that.dataURLtoFile(base64,'name')
|
|
86
85
|
let promise = uploadImageByBase64(ossConfig,blob);
|
|
87
86
|
promise.then((res)=>{
|
|
88
87
|
console.debug("upload base64 reslut",res);
|
|
88
|
+
if (res&&res.url){
|
|
89
|
+
that.poster = res.url
|
|
90
|
+
if (!reg.test(that.poster)){
|
|
91
|
+
that.poster +='.png'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
console.debug('poster',that.poster)
|
|
89
95
|
});
|
|
90
|
-
/*output.appendChild(img);*/
|
|
91
96
|
};
|
|
92
97
|
|
|
93
98
|
initialize();
|