1
+ /*
2
+ * @Author : ly525
3
+ * @Date : 2019-12-01 18:11:50
4
+ * @LastEditors : ly525
5
+ * @LastEditTime : 2020-01-13 00:31:39
6
+ * @FilePath : /luban-h5/front-end/h5/src/components/plugins/lbp-video.js
7
+ * @Github : https://github.com/ly525/luban-h5
8
+ * @Description : Do not edit
9
+ * @Copyright 2018 - 2019 luban-h5. All Rights Reserved
10
+ */
1
11
import playIcon from './play.svg'
2
12
import './styles/video.scss'
3
13
// 这里有个动画演示,可以用来学习 CSS:《CSS制作播放、暂停按钮》https://codepen.io/chriscoyier/full/lotjh
@@ -7,46 +17,81 @@ export default {
7
17
props : {
8
18
src : {
9
19
type : String ,
10
- default : `` ,
20
+ default : `http://localhost:1337/uploads/419a4b0c60f9488c9d44c398dc987471.mp4 ` ,
11
21
editor : {
12
- type : 'a-input ' ,
13
- label : '视频url ' ,
22
+ type : 'lbs-video-gallery ' ,
23
+ label : '视频 ' ,
14
24
prop : {
15
25
type : 'textarea'
16
- } ,
17
- extra : ( h ) => {
18
- return < a href = 'https://github.com/ly525/luban-h5/issues/85' target = '_blank' > 教程(Tutorial)</ a >
19
26
}
20
27
}
21
28
} ,
22
29
disabled : {
23
30
type : Boolean ,
24
31
default : false
32
+ } ,
33
+ useIframe : {
34
+ type : Boolean ,
35
+ default : false ,
36
+ editor : {
37
+ type : 'a-switch' ,
38
+ label : '使用iframe'
39
+ }
40
+ } ,
41
+ iframeSrc : {
42
+ type : String ,
43
+ default : '' ,
44
+ editor : {
45
+ type : 'a-input' ,
46
+ label : 'iframe 地址' ,
47
+ prop : {
48
+ type : 'textarea' ,
49
+ placeholder : '只有使用iframe打开的时候,这个才有效'
50
+ } ,
51
+ extra : ( h ) => {
52
+ return '「使用iframe」打开的时候,这个才有效;上传视频请忽略该配置'
53
+ }
54
+ }
25
55
}
26
56
} ,
27
57
watch : {
28
58
src ( ) {
29
59
this . appendIframe ( )
60
+ } ,
61
+ disabled ( ) {
62
+ this . appendIframe ( )
63
+ } ,
64
+ useIframe ( ) {
65
+ this . appendIframe ( )
66
+ } ,
67
+ iframeSrc ( ) {
68
+ this . appendIframe ( )
30
69
}
31
70
} ,
32
71
mounted ( ) {
33
72
this . appendIframe ( )
34
73
} ,
35
74
methods : {
36
75
appendIframe ( ) {
37
- if ( this . src ) {
38
- this . $el . innerHTML = this . src
76
+ if ( this . useIframe && this . iframeSrc ) {
77
+ // v-html
78
+ this . $refs . iframeWrapper && ( this . $refs . iframeWrapper . innerHTML = this . iframeSrc )
39
79
}
80
+ // else if (this.src) {
81
+ // this.$refs.videoTag && (this.$refs.videoTag.innerHTML = `<source type="video/mp4" src=${this.src} />`)
82
+ // }
40
83
}
41
84
} ,
42
85
render ( h ) {
43
86
const style = this . disabled ? { 'pointer-events' : 'none' } : { }
44
87
return (
45
88
< div class = "lbc-video" style = { style } >
46
89
{
47
- this . disabled
48
- ? < video playsinline = "true" webkit-playsinline = "" width = "100%" height = "100%" poster = { playIcon } > < source type = "video/mp4" /> </ video >
49
- : < div > </ div >
90
+ this . useIframe
91
+ ? < div ref = "iframeWrapper" > < img src = { playIcon } width = "100%" height = "100%" /> </ div >
92
+ : < video playsinline = "true" webkit-playsinline = "" width = "100%" height = "100%" poster = { playIcon } ref = "videoTag" controls >
93
+ < source type = "video/mp4" src = { this . src } />
94
+ </ video >
50
95
}
51
96
</ div >
52
97
)
0 commit comments