im ok
This commit is contained in:
48
components/GoEasyVideoPlayer/goEasyVideoPlayer.js
Normal file
48
components/GoEasyVideoPlayer/goEasyVideoPlayer.js
Normal 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();
|
||||
}
|
||||
}
|
||||
})
|
||||
4
components/GoEasyVideoPlayer/goEasyVideoPlayer.json
Normal file
4
components/GoEasyVideoPlayer/goEasyVideoPlayer.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
3
components/GoEasyVideoPlayer/goEasyVideoPlayer.wxml
Normal file
3
components/GoEasyVideoPlayer/goEasyVideoPlayer.wxml
Normal 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>
|
||||
11
components/GoEasyVideoPlayer/goEasyVideoPlayer.wxss
Normal file
11
components/GoEasyVideoPlayer/goEasyVideoPlayer.wxss
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user