Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
d69d2ffa
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6006
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
d69d2ffa
编写于
8月 14, 2024
作者:
DCloud-yinjiacheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新video示例和自动化测试用例
上级
3f3c3f31
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
62 addition
and
26 deletion
+62
-26
pages/component/video/video.test.js
pages/component/video/video.test.js
+12
-8
pages/component/video/video.uvue
pages/component/video/video.uvue
+50
-18
static/test-video/fast-backward.png
static/test-video/fast-backward.png
+0
-0
static/test-video/fast-forward.png
static/test-video/fast-forward.png
+0
-0
未找到文件。
pages/component/video/video.test.js
浏览文件 @
d69d2ffa
...
@@ -105,10 +105,7 @@ describe('component-native-video', () => {
...
@@ -105,10 +105,7 @@ describe('component-native-video', () => {
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
return
return
}
}
await
page
.
setData
({
await
page
.
callMethod
(
'
seek
'
,
10
);
pos
:
10
});
await
page
.
callMethod
(
'
seek
'
);
start
=
Date
.
now
();
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventWaiting
'
))
&&
(
await
page
.
data
(
'
eventProgress
'
))
||
(
Date
.
now
()
-
start
>
1000
);
return
(
await
page
.
data
(
'
eventWaiting
'
))
&&
(
await
page
.
data
(
'
eventProgress
'
))
||
(
Date
.
now
()
-
start
>
1000
);
...
@@ -169,10 +166,7 @@ describe('component-native-video', () => {
...
@@ -169,10 +166,7 @@ describe('component-native-video', () => {
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
return
return
}
}
await
page
.
setData
({
await
page
.
callMethod
(
'
seek
'
,
120
);
pos
:
120
});
await
page
.
callMethod
(
'
seek
'
);
start
=
Date
.
now
();
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventEnded
'
))
||
(
Date
.
now
()
-
start
>
5000
);
return
(
await
page
.
data
(
'
eventEnded
'
))
||
(
Date
.
now
()
-
start
>
5000
);
...
@@ -220,6 +214,16 @@ describe('component-native-video', () => {
...
@@ -220,6 +214,16 @@ describe('component-native-video', () => {
});
});
});
});
it
(
'
test sub component
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
return
await
page
.
setData
({
subCompEnable
:
true
,
subCompShow
:
true
});
await
page
.
waitFor
(
100
);
expect
(
await
page
.
callMethod
(
'
hasSubComponent
'
)).
toBe
(
true
);
});
it
(
'
test format
'
,
async
()
=>
{
it
(
'
test format
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
'
/pages/component/video/video-format
'
);
page
=
await
program
.
navigateTo
(
'
/pages/component/video/video-format
'
);
await
page
.
waitFor
(
1000
);
await
page
.
waitFor
(
1000
);
...
...
pages/component/video/video.uvue
浏览文件 @
d69d2ffa
...
@@ -11,7 +11,8 @@
...
@@ -11,7 +11,8 @@
@ended="onEnded" @timeupdate="onTimeUpdate" @waiting="onWaiting" @error="onError" @progress="onProgress"
@ended="onEnded" @timeupdate="onTimeUpdate" @waiting="onWaiting" @error="onError" @progress="onProgress"
@fullscreenclick="onFullScreenClick" @controlstoggle="onControlsToggle" @fullscreenchange="onFullScreenChange">
@fullscreenclick="onFullScreenClick" @controlstoggle="onControlsToggle" @fullscreenchange="onFullScreenChange">
<!-- #ifdef APP-ANDROID -->
<!-- #ifdef APP-ANDROID -->
<image class="custom-play-btn" v-if="customPlayBtnEnable" v-show="customPlayBtnShow" src="/static/play.png" @tap="play" />
<image v-if="subCompEnable && subCompShow" class="img-fast-backward" src="../../../static/test-video/fast-backward.png" @tap="fastBackward"></image>
<image v-if="subCompEnable && subCompShow" class="img-fast-forward" src="../../../static/test-video/fast-forward.png" @tap="fastForward"></image>
<!-- #endif -->
<!-- #endif -->
</video>
</video>
<scroll-view class="uni-padding-wrap uni-common-mt uni-flex-item">
<scroll-view class="uni-padding-wrap uni-common-mt uni-flex-item">
...
@@ -21,9 +22,9 @@
...
@@ -21,9 +22,9 @@
</navigator>
</navigator>
</view>
</view>
<!-- #ifdef APP-ANDROID -->
<!-- #ifdef APP-ANDROID -->
<view class="uni-flex uni-btn-v" style="justify-content: space-between;">
<view class="uni-flex uni-btn-v" style="justify-content: space-between;
align-items: center;
">
<text class="uni-title"
>中间播放按钮是否替换为子组件
</text>
<text class="uni-title"
style="width: 80%;">子组件实现快进、快退功能(全屏后显示)
</text>
<switch :checked="
customPlayBtnEnable" :disabled="!customPlayBtnShow" @change="onCustomPlayBtn
EnableChange" />
<switch :checked="
subCompEnable" @change="onSubComp
EnableChange" />
</view>
</view>
<!-- #endif -->
<!-- #endif -->
<view class="uni-title">
<view class="uni-title">
...
@@ -37,7 +38,7 @@
...
@@ -37,7 +38,7 @@
</view>
</view>
<view class="uni-btn-v">
<view class="uni-btn-v">
<input class="input" placeholder="输入要跳转的位置,单位s" type="number" @input="onSeekInput"></input>
<input class="input" placeholder="输入要跳转的位置,单位s" type="number" @input="onSeekInput"></input>
<button type="primary" @click="seek">跳转到指定位置</button>
<button type="primary" @click="seek
(this.pos)
">跳转到指定位置</button>
</view>
</view>
<view class="uni-btn-v">
<view class="uni-btn-v">
<enum-data title="选择进入全屏时的视频方向" :items="directionItemTypes" @change="onRequestFullScreenDirectionChange"></enum-data>
<enum-data title="选择进入全屏时的视频方向" :items="directionItemTypes" @change="onRequestFullScreenDirectionChange"></enum-data>
...
@@ -96,6 +97,9 @@
...
@@ -96,6 +97,9 @@
<script>
<script>
import { ItemType } from '@/components/enum-data/enum-data';
import { ItemType } from '@/components/enum-data/enum-data';
// #ifdef APP-ANDROID
import ViewGroup from 'android.view.ViewGroup';
// #endif
export default {
export default {
onReady() {
onReady() {
this.videoContext = uni.createVideoContext('video');
this.videoContext = uni.createVideoContext('video');
...
@@ -176,8 +180,10 @@
...
@@ -176,8 +180,10 @@
rate: 1,
rate: 1,
rateItemTypes: [{ "value": 0, "name": "0.5" }, { "value": 1, "name": "0.8" }, { "value": 2, "name": "1.0" }, { "value": 3, "name": "1.25" }, { "value": 4, "name": "1.5" }] as ItemType[],
rateItemTypes: [{ "value": 0, "name": "0.5" }, { "value": 1, "name": "0.8" }, { "value": 2, "name": "1.0" }, { "value": 3, "name": "1.25" }, { "value": 4, "name": "1.5" }] as ItemType[],
rateItems: [0.5, 0.8, 1.0, 1.25, 1.5],
rateItems: [0.5, 0.8, 1.0, 1.25, 1.5],
customPlayBtnEnable: false,
subCompEnable: false,
customPlayBtnShow: true,
subCompShow: false,
curPos: 0,
endPos: 0,
// 自动化测试
// 自动化测试
autoTest: false,
autoTest: false,
isPlaying: false,
isPlaying: false,
...
@@ -208,9 +214,9 @@
...
@@ -208,9 +214,9 @@
(uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
(uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
// this.videoContext?.pause();
// this.videoContext?.pause();
},
},
seek: function () {
seek: function (
pos : number
) {
console.log("seek -> " +
this.
pos);
console.log("seek -> " + pos);
this.videoContext?.seek(
this.
pos);
this.videoContext?.seek(pos);
},
},
onSeekInput: function (event : UniInputEvent) {
onSeekInput: function (event : UniInputEvent) {
this.pos = parseInt(event.detail.value);
this.pos = parseInt(event.detail.value);
...
@@ -227,7 +233,6 @@
...
@@ -227,7 +233,6 @@
console.log("stop");
console.log("stop");
uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
// this.videoContext?.stop();
// this.videoContext?.stop();
this.customPlayBtnShow = true;
},
},
sendDanmu: function () {
sendDanmu: function () {
console.log("sendDanmu -> " + this.danmu);
console.log("sendDanmu -> " + this.danmu);
...
@@ -245,6 +250,16 @@
...
@@ -245,6 +250,16 @@
onPlaybackRateChange: function (value : number) {
onPlaybackRateChange: function (value : number) {
this.rate = this.rateItems[value];
this.rate = this.rateItems[value];
},
},
fastBackward: function () {
let pos = this.curPos - 15;
if (pos < 0) pos = 0;
this.seek(pos);
},
fastForward: function () {
let pos = this.curPos + 15;
if (pos > this.endPos) pos = this.endPos;
this.seek(pos);
},
// 属性
// 属性
onSrcComfirm: function (event : UniInputConfirmEvent) {
onSrcComfirm: function (event : UniInputConfirmEvent) {
let value = event.detail.value;
let value = event.detail.value;
...
@@ -376,15 +391,14 @@
...
@@ -376,15 +391,14 @@
this.header = json as UTSJSONObject;
this.header = json as UTSJSONObject;
console.log("header -> " + JSON.stringify(this.header))
console.log("header -> " + JSON.stringify(this.header))
},
},
on
CustomPlayBtn
EnableChange: function (event : UniSwitchChangeEvent) {
on
SubComp
EnableChange: function (event : UniSwitchChangeEvent) {
this.
customPlayBtn
Enable = event.detail.value;
this.
subComp
Enable = event.detail.value;
},
},
// 事件
// 事件
onPlay: function (res : UniEvent) {
onPlay: function (res : UniEvent) {
console.log(res.type);
console.log(res.type);
this.isPlaying = true;
this.isPlaying = true;
this.isPause = false;
this.isPause = false;
this.customPlayBtnShow = false;
if (this.autoTest) {
if (this.autoTest) {
this.eventPlay = {
this.eventPlay = {
"tagName": res.target?.tagName,
"tagName": res.target?.tagName,
...
@@ -414,6 +428,8 @@
...
@@ -414,6 +428,8 @@
},
},
onTimeUpdate: function (res : UniVideoTimeUpdateEvent) {
onTimeUpdate: function (res : UniVideoTimeUpdateEvent) {
console.log(res.type + " -> " + JSON.stringify(res.detail));
console.log(res.type + " -> " + JSON.stringify(res.detail));
this.curPos = res.detail.currentTime;
this.endPos = res.detail.duration;
if (this.autoTest) {
if (this.autoTest) {
this.eventTimeupdate = {
this.eventTimeupdate = {
"tagName": res.target?.tagName,
"tagName": res.target?.tagName,
...
@@ -425,6 +441,7 @@
...
@@ -425,6 +441,7 @@
},
},
onFullScreenChange: function (res : UniVideoFullScreenChangeEvent) {
onFullScreenChange: function (res : UniVideoFullScreenChangeEvent) {
console.log(res.type + " -> " + JSON.stringify(res.detail));
console.log(res.type + " -> " + JSON.stringify(res.detail));
this.subCompShow = res.detail.fullScreen;
if (this.autoTest) {
if (this.autoTest) {
this.eventFullscreenchange = {
this.eventFullscreenchange = {
"tagName": res.target?.tagName,
"tagName": res.target?.tagName,
...
@@ -498,7 +515,13 @@
...
@@ -498,7 +515,13 @@
this.isError = true;
this.isError = true;
}
}
})
})
},
// #ifdef APP-ANDROID
hasSubComponent() : boolean {
const view = uni.getElementById('video')?.getAndroidView<ViewGroup>();
return view == null ? false : view.getChildCount() > 1;
}
}
// #endif
}
}
}
}
</script>
</script>
...
@@ -519,12 +542,21 @@
...
@@ -519,12 +542,21 @@
margin: 10px;
margin: 10px;
}
}
.
custom-play-btn
{
.
img-fast-backward
{
width:
6
0px;
width:
4
0px;
height:
6
0px;
height:
4
0px;
top: 50%;
top: 50%;
left:
50
%;
left:
12
%;
transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
position: absolute;
position: absolute;
}
}
.img-fast-forward {
width: 40px;
height: 40px;
top: 50%;
right: 12%;
transform: translate(50%, -50%);
position: absolute;
}
</style>
</style>
static/test-video/fast-backward.png
0 → 100644
浏览文件 @
d69d2ffa
1.1 KB
static/test-video/fast-forward.png
0 → 100644
浏览文件 @
d69d2ffa
1.1 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录