镜子功能发现功能
This commit is contained in:
91
pages/found2/swiper2.js
Normal file
91
pages/found2/swiper2.js
Normal file
@@ -0,0 +1,91 @@
|
||||
// pages/index5/index5.js
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
viList: [{
|
||||
vio: 'https://assets.mixkit.co/videos/preview/mixkit-movement-in-a-large-avenue-at-night-in-timelapse-44688-large.mp4',
|
||||
avatar: 'https://profile-avatar.csdnimg.cn/6ef2193c2e9649c88356336c626e5777_m0_64944135.jpg',
|
||||
name: 'xiaoshen',
|
||||
id:1,
|
||||
},
|
||||
{
|
||||
vio: 'https://sgy-test-cdn.oss-cn-hangzhou.aliyuncs.com/attachments/2023/11/17/de99704d307d216800e08584111ca61f.mp4',
|
||||
avatar: ' https://profile.csdnimg.cn/7/A/9/1_2201_75886543',
|
||||
name: 'kami',
|
||||
id:2,
|
||||
},
|
||||
{
|
||||
vio: 'https://sgy-test-cdn.oss-cn-hangzhou.aliyuncs.com/attachments/2023/11/17/574217650a315865ce8833c31f8d9091.mp4',
|
||||
avatar: ' https://profile.csdnimg.cn/7/A/9/1_2201_75886543',
|
||||
name: 'kami',
|
||||
id:3
|
||||
},
|
||||
{
|
||||
vio: 'https://sgy-test-cdn.oss-cn-hangzhou.aliyuncs.com/attachments/2023/11/16/eb8debf3c9ef26eb6829a533709c08a1.mp4',
|
||||
avatar: ' https://profile.csdnimg.cn/7/A/9/1_2201_75886543',
|
||||
name: 'kami',
|
||||
id:4
|
||||
},
|
||||
{
|
||||
vio: 'https://sgy-test-cdn.oss-cn-hangzhou.aliyuncs.com/attachments/2023/11/17/ecb93a818d0e507b6d1a962ab83490c9.mp4',
|
||||
avatar: ' https://profile.csdnimg.cn/7/A/9/1_2201_75886543',
|
||||
name: 'kami',
|
||||
id:5
|
||||
}
|
||||
],
|
||||
stopIndex:0,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// 调用播放视频方法
|
||||
this.startUp()
|
||||
},
|
||||
|
||||
// 进页面时播放视频
|
||||
startUp() {
|
||||
// 获取video节点
|
||||
let createVideoContext = wx.createVideoContext('video0')
|
||||
// 播放视频
|
||||
createVideoContext.play()
|
||||
},
|
||||
|
||||
// 切换视频的时候播放视频
|
||||
// 注:此方法视频如果过大可能会叠音,所以视频需要压缩,或者可以尝试循环节点关闭视频
|
||||
nextVideo(e) {
|
||||
// 播放当前页面视频
|
||||
let index = 'video' + e.detail.current
|
||||
this.setData({
|
||||
stopIndex:e.detail.current
|
||||
})
|
||||
this.playVio(index)
|
||||
// 暂停前一个页面视频
|
||||
if (e.detail.current - 1 >= 0) {
|
||||
let index1 = 'video' + (e.detail.current - 1)
|
||||
this.pauseVio(index1)
|
||||
}
|
||||
// 暂停后一个页面视频
|
||||
if (e.detail.current + 1 < this.data.viList.length) {
|
||||
let index2 = 'video' + (e.detail.current + 1)
|
||||
this.pauseVio(index2)
|
||||
}
|
||||
},
|
||||
|
||||
// 播放视频
|
||||
playVio(index) {
|
||||
// 获取video节点
|
||||
let createVideoContext = wx.createVideoContext(index)
|
||||
// 播放视频
|
||||
createVideoContext.play()
|
||||
},
|
||||
|
||||
// 暂停视频
|
||||
pauseVio(index) {
|
||||
// 获取video节点
|
||||
let createVideoContext = wx.createVideoContext(index)
|
||||
// 暂停视频
|
||||
createVideoContext.seek(0)
|
||||
createVideoContext.pause()
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user