Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
694f3ed0
U
uni-app
项目概览
wzj-java
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
694f3ed0
编写于
11月 16, 2018
作者:
X
xiaoyucoding
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify: 优化发送弹幕的逻辑
上级
35f28e27
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
21 deletion
+19
-21
examples/hello-uniapp/pages/component/video/video.vue
examples/hello-uniapp/pages/component/video/video.vue
+19
-21
未找到文件。
examples/hello-uniapp/pages/component/video/video.vue
浏览文件 @
694f3ed0
...
...
@@ -4,25 +4,24 @@
<view
class=
"uni-padding-wrap uni-common-mt"
>
<view>
<video
id=
"myVideo"
src=
"https://www.dcloud.io/uniapp/wap2appvsnative.mp4"
@
error=
"videoErrorCallback"
:danmu-list=
"danmuList"
enable-danmu
danmu-btn
controls
></video>
enable-danmu
danmu-btn
controls
></video>
</view>
<view
class=
"uni-list uni-common-mt"
>
<view
class=
"uni-list-cell"
>
<view>
<view
class=
"uni-label"
>
弹幕内容
</view>
</view>
<view
class=
"uni-list-cell-db"
>
<input
@
blur=
"bindInputBlur
"
class=
"uni-input"
type=
"text"
placeholder=
"在此处输入弹幕内容"
/>
<input
v-model=
"danmuValue
"
class=
"uni-input"
type=
"text"
placeholder=
"在此处输入弹幕内容"
/>
</view>
</view>
</view>
<view
class=
"uni-btn-v"
>
<button
@
tap=
"bindSendDanmu"
class=
"page-body-button"
>
发送弹幕
</button>
</view>
<button
@
click=
"sendDanmu"
class=
"page-body-button"
>
发送弹幕
</button>
</view>
</view>
</view>
</view>
</
template
>
<
script
>
export
default
{
...
...
@@ -30,7 +29,6 @@
return
{
title
:
'
video
'
,
src
:
''
,
inputValue
:
''
,
danmuList
:
[{
text
:
'
第 1s 出现的弹幕
'
,
color
:
'
#ff0000
'
,
...
...
@@ -41,30 +39,28 @@
color
:
'
#ff00ff
'
,
time
:
3
}
]
],
danmuValue
:
''
}
},
onReady
:
function
(
res
)
{
onReady
:
function
(
res
)
{
this
.
videoContext
=
uni
.
createVideoContext
(
'
myVideo
'
)
},
methods
:
{
bindInputBlur
:
function
(
e
)
{
this
.
inputValue
=
e
.
target
.
value
},
bindSendDanmu
:
function
()
{
sendDanmu
:
function
()
{
this
.
videoContext
.
sendDanmu
({
text
:
this
.
input
Value
,
text
:
this
.
danmu
Value
,
color
:
this
.
getRandomColor
()
})
});
this
.
danmuValue
=
''
;
},
videoErrorCallback
:
function
(
e
)
{
console
.
log
(
e
.
target
.
errMsg
);
videoErrorCallback
:
function
(
e
)
{
uni
.
showModal
({
content
:
e
.
target
.
errMsg
,
showCancel
:
false
content
:
e
.
target
.
errMsg
,
showCancel
:
false
})
},
getRandomColor
:
function
()
{
getRandomColor
:
function
()
{
const
rgb
=
[]
for
(
let
i
=
0
;
i
<
3
;
++
i
)
{
let
color
=
Math
.
floor
(
Math
.
random
()
*
256
).
toString
(
16
)
...
...
@@ -78,5 +74,7 @@
</
script
>
<
style
>
video
{
width
:
690
upx
;}
</
style
>
\ No newline at end of file
video
{
width
:
690
upx
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录