提交 f6213816 编写于 作者: 蓝色的小猫咪's avatar 蓝色的小猫咪

Merge branch 'master' of https://github.com/dcloudio/uni-app

......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>local web-view</title>
<title>本地网页</title>
<style type="text/css">
.btn {
display: block;
......
......@@ -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.inputValue,
text: this.danmuValue,
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:690upx;}
</style>
\ No newline at end of file
video {
width: 690upx;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册