Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
98ff0630
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
98ff0630
编写于
8月 22, 2023
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新 示例模板竖划视频为全屏 修复 1. 视频加载和播放图标层叠问题 2. 封面不显示的问题(改用网络图片)
上级
04d5e026
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
75 addition
and
35 deletion
+75
-35
pages.json
pages.json
+2
-2
pages/template/swiper-vertical-video/swiper-vertical-video.uvue
...template/swiper-vertical-video/swiper-vertical-video.uvue
+73
-33
static/template/scroll-fold-nav/back.png
static/template/scroll-fold-nav/back.png
+0
-0
未找到文件。
pages.json
浏览文件 @
98ff0630
...
...
@@ -668,7 +668,7 @@
{
"path"
:
"pages/template/drop-card/drop-card"
,
"style"
:
{
"navigationBarTitleText"
:
""
"navigationBarTitleText"
:
"
drop-card
"
}
},
{
...
...
@@ -698,7 +698,7 @@
{
"path"
:
"pages/template/swiper-vertical-video/swiper-vertical-video"
,
"style"
:
{
"navigation
BarTitleText"
:
"
"
"navigation
Style"
:
"custom
"
}
},
{
...
...
pages/template/swiper-vertical-video/swiper-vertical-video.uvue
浏览文件 @
98ff0630
<template>
<view class="page">
<view @click="back" class="nav-back">
<image class="back-img" src="/static/template/scroll-fold-nav/back.png" mode="widthFix"></image>
</view>
<swiper class="swiper" :current="current" :circular="index != 0" :vertical="true" @change="onSwiperChange" @transition="onTransition">
<swiper-item class="swiper-item" v-for="(item,i) in visibleList" :key="i">
<video ref="video" class="video-box"
:id="item._id
" :src="item.src" :poster="item.poster_src" :show-center-play-btn="false" :autoplay="false" :controls="false" :loop="true" @play="onPlay(i)" @pause="onPause(i)"></video>
<video ref="video" class="video-box"
objectFit="cover" :id="item._id" @loadstart="onLoadstart(i)
" :src="item.src" :poster="item.poster_src" :show-center-play-btn="false" :autoplay="false" :controls="false" :loop="true" @play="onPlay(i)" @pause="onPause(i)"></video>
<view class="video-cover" @click="changeState(i)">
<image v-if="
!state[i]
" class="play-btn" src="/static/template/swiper-vertical-video/play.png" mode="widthFix"></image>
<image v-if="
state[i] === 'onPause'
" class="play-btn" src="/static/template/swiper-vertical-video/play.png" mode="widthFix"></image>
</view>
<view class="video-info">
<view class="video-info"
v-if="0"
>
<text class="video-info-text">容器:第 {{i}} 个</text>
<text class="video-info-text">内容:{{item.content}}</text>
</view>
...
...
@@ -14,7 +17,7 @@
</swiper>
<view class="debug-info" v-if="0">
<text class="status-text">debug-info 播放状态:</text>
<text class="status-text" v-for="(value,index) in state">第{{index+1}}个:{{
value?'播放中':'已暂停'
}}</text>
<text class="status-text" v-for="(value,index) in state">第{{index+1}}个:{{
value
}}</text>
</view>
</view>
</template>
...
...
@@ -31,7 +34,7 @@
visibleList: [] as ListItem[],// 提高性能 可见的只有3个
current: 0 as number,
index: 0,
state: [
false, false, false] as boolean[]
state: [
"unPlay", "unPlay", "unPlay"] as string[]
}
},
beforeCreate() {
...
...
@@ -66,13 +69,13 @@
}
},
current(current) {
this.state.forEach((val :
boolean
, index : number) => {
this.state.forEach((val :
string
, index : number) => {
if (index === current) {
this.doPlay(current)
} else if (val) {
} else if (val
=== 'onPlay'
) {
// 除了选中的其他已经播放的都需要停止
this.do
Pause
(index)
console.log('index:' + index + '已被执行
暂停
');
this.do
Stop
(index)
console.log('index:' + index + '已被执行
停止
');
}
})
}
...
...
@@ -83,45 +86,51 @@
},
methods: {
changeState(index : number) {
if (this.state[index]) {
if (this.state[index]
=== 'onPlay'
) {
this.doPause(index)
} else {
this.doPlay(current)
}
},
onLoadstart(index : number) {
console.error("onLoadstart video" + index );
},
doPlay(index : number) {
// console.log("doPlay video" + index,(this.$refs["video"] as VideoNode[])[0] );
(this.$refs["video"] as VideoNode[])[index].play()
},
doStop(index : number) {
(this.$refs["video"] as VideoNode[])[index].stop()
console.log("doPause video-" + index);
// TODO 临时方案:解决.stop()时触发了doPause的问题
setTimeout(()=>{
this.state[index] = 'unPlay'
},1000)
},
doPause(index : number) {
(this.$refs["video"] as VideoNode[])[index].pause()
console.log("doPause video-" + index);
},
onPause(index : number) {
this.state[index] =
false
this.state[index] =
'onPause'
console.log('onPause', index);
},
onPlay(index : number) {
this.state[index] =
true
this.state[index] =
'onPlay'
console.log('onPlay', index);
},
getData() : ListItem[] {
/* Promise 暂不支持
Promise<void>
return new Promise((resolve) => {
resolve();
});*/
let videoUrlList = [
'https://qiniu-web-assets.dcloud.net.cn/uni
doc/zh/
video/uts.mp4',
'https://qiniu-web-assets.dcloud.net.cn/uni
doc/zh/
video/uni-ai.mp4',
'https://qiniu-web-assets.dcloud.net.cn/uni
doc/zh/
video/uni-verify.mp4'
'https://qiniu-web-assets.dcloud.net.cn/uni
-app-x/static/video/swiper-vertical-
video/uts.mp4',
'https://qiniu-web-assets.dcloud.net.cn/uni
-app-x/static/video/swiper-vertical-
video/uni-ai.mp4',
'https://qiniu-web-assets.dcloud.net.cn/uni
-app-x/static/video/swiper-vertical-
video/uni-verify.mp4'
] as string[]
let posterSrcList = [
'
/static/template/swiper-vertical-video/
poster/uni-uts.jpg',
'
/static/template/swiper-vertical-video/
poster/uni-ai.jpg',
'
/static/template/swiper-vertical-video/
poster/uni-verify.jpg'
'
https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/images/swiper-vertical-video-
poster/uni-uts.jpg',
'
https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/images/swiper-vertical-video-
poster/uni-ai.jpg',
'
https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/images/swiper-vertical-video-
poster/uni-verify.jpg'
] as string[]
let list = [] as ListItem[];
...
...
@@ -143,6 +152,19 @@
},
onTransition(/*e : SwiperTransitionEvent*/) {
// console.log('onTransition e.detail.dx', e.detail.dx);
},
back() {
uni.navigateBack({
success(result) {
console.log('navigateBack success', result.errMsg)
},
fail(error) {
console.log('navigateBack fail', error.errMsg)
},
complete(result) {
console.log('navigateBack complete', result.errMsg)
},
})
}
}
}
...
...
@@ -179,8 +201,8 @@
}
.play-btn {
width:
30
px;
height:
30
px;
width:
80r
px;
height:
80r
px;
color: #FFF;
}
...
...
@@ -206,4 +228,22 @@
color:red;
padding: 15px;
}
.nav-back {
position: absolute;
top: 20px;
left: 8px;
background-color: rgba(220, 220, 220, 0.8);
border-radius: 100px;
width: 24px;
height: 24px;
justify-content: center;
align-items: center;
z-index: 10;
}
.nav-back .back-img {
width: 14px;
height: 14px;
}
</style>
\ No newline at end of file
static/template/scroll-fold-nav/back.png
查看替换文件 @
04d5e026
浏览文件 @
98ff0630
2.8 KB
|
W:
|
H:
3.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录