Skip to content

Commit 2e6cd48

Browse files
committed
feat: upload video
1 parent d7866bf commit 2e6cd48

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

front-end/h5/src/components/plugins/lbp-video.js

+56-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
*/
111
import playIcon from './play.svg'
212
import './styles/video.scss'
313
// 这里有个动画演示,可以用来学习 CSS:《CSS制作播放、暂停按钮》https://codepen.io/chriscoyier/full/lotjh
@@ -7,46 +17,81 @@ export default {
717
props: {
818
src: {
919
type: String,
10-
default: ``,
20+
default: `http://localhost:1337/uploads/419a4b0c60f9488c9d44c398dc987471.mp4`,
1121
editor: {
12-
type: 'a-input',
13-
label: '视频url',
22+
type: 'lbs-video-gallery',
23+
label: '视频',
1424
prop: {
1525
type: 'textarea'
16-
},
17-
extra: (h) => {
18-
return <a href='https://github.com/ly525/luban-h5/issues/85' target='_blank'>教程(Tutorial)</a>
1926
}
2027
}
2128
},
2229
disabled: {
2330
type: Boolean,
2431
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+
}
2555
}
2656
},
2757
watch: {
2858
src () {
2959
this.appendIframe()
60+
},
61+
disabled () {
62+
this.appendIframe()
63+
},
64+
useIframe () {
65+
this.appendIframe()
66+
},
67+
iframeSrc () {
68+
this.appendIframe()
3069
}
3170
},
3271
mounted () {
3372
this.appendIframe()
3473
},
3574
methods: {
3675
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)
3979
}
80+
// else if (this.src) {
81+
// this.$refs.videoTag && (this.$refs.videoTag.innerHTML = `<source type="video/mp4" src=${this.src} />`)
82+
// }
4083
}
4184
},
4285
render (h) {
4386
const style = this.disabled ? { 'pointer-events': 'none' } : { }
4487
return (
4588
<div class="lbc-video" style={style}>
4689
{
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>
5095
}
5196
</div>
5297
)

0 commit comments

Comments
 (0)