This commit is contained in:
2021-04-07 15:18:17 +08:00
parent dfdf73fdfc
commit ab7a7cf62f
88 changed files with 2974 additions and 4 deletions

View File

@@ -0,0 +1,48 @@
Component({
options: {
multipleSlots: true, // 在组件定义时的选项中启用多slot支持
},
data: {
videoContext: null,
show : false,
src : '',
duration : 0
},
methods: {
play({url='', duration=0}) {
this.setData({
show : true,
src : url,
duration : duration,
videoContext: wx.createVideoContext('videoPlayer', this)
})
},
onPlay () {
console.log('onplay');
this.data.videoContext.requestFullScreen({
direction : 0
})
},
onFullScreenChange(e) {
// 视频的全屏与退出全屏都会执行
//当退出全屏播放时,隐藏播放器
if(this.data.show && !e.detail.fullScreen){
this.setData({
show : false
})
this.data.videoContext.stop();
}
}
},
attached: function() {
// 在组件实例进入页面节点树时执行
},
detached: function() {
// 在组件实例被从页面节点树移除时执行
if(this.data.videoContext != null){
this.data.videoContext.stop();
}
}
})

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,3 @@
<view class="goeasy-video-player" style="width0;height:0;overflow:hidden">
<video id="videoPlayer" wx:if="{{show}}" src="{{src}}" autoplay="true" custom-cache="{{false}}" bindfullscreenchange="onFullScreenChange" bindplay="onPlay" controls duration="{{duration}}"></video>
</view>

View File

@@ -0,0 +1,11 @@
.goeasy-video-player {
width: 100%;
height: 100%;
}
.mask {
position: absolute;
top: 0;
z-index: 1;
opacity: 0.6;
background: #333;
}