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

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

...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>local web-view</title> <title>本地网页</title>
<style type="text/css"> <style type="text/css">
.btn { .btn {
display: block; display: block;
......
...@@ -4,25 +4,24 @@ ...@@ -4,25 +4,24 @@
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view> <view>
<video id="myVideo" src="https://www.dcloud.io/uniapp/wap2appvsnative.mp4" @error="videoErrorCallback" :danmu-list="danmuList" <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>
<view class="uni-list uni-common-mt"> <view class="uni-list uni-common-mt">
<view class="uni-list-cell"> <view class="uni-list-cell">
<view> <view>
<view class="uni-label">弹幕内容</view> <view class="uni-label">弹幕内容</view>
</view> </view>
<view class="uni-list-cell-db"> <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>
</view> </view>
<view class="uni-btn-v"> <view class="uni-btn-v">
<button @tap="bindSendDanmu" class="page-body-button">发送弹幕</button> <button @click="sendDanmu" class="page-body-button">发送弹幕</button>
</view>
</view> </view>
</view> </view>
</view> </view>
</view>
</template> </template>
<script> <script>
export default { export default {
...@@ -30,7 +29,6 @@ ...@@ -30,7 +29,6 @@
return { return {
title: 'video', title: 'video',
src: '', src: '',
inputValue: '',
danmuList: [{ danmuList: [{
text: '第 1s 出现的弹幕', text: '第 1s 出现的弹幕',
color: '#ff0000', color: '#ff0000',
...@@ -41,30 +39,28 @@ ...@@ -41,30 +39,28 @@
color: '#ff00ff', color: '#ff00ff',
time: 3 time: 3
} }
] ],
danmuValue: ''
} }
}, },
onReady: function (res) { onReady: function(res) {
this.videoContext = uni.createVideoContext('myVideo') this.videoContext = uni.createVideoContext('myVideo')
}, },
methods: { methods: {
bindInputBlur: function (e) { sendDanmu: function() {
this.inputValue = e.target.value
},
bindSendDanmu: function () {
this.videoContext.sendDanmu({ this.videoContext.sendDanmu({
text: this.inputValue, text: this.danmuValue,
color: this.getRandomColor() color: this.getRandomColor()
}) });
this.danmuValue = '';
}, },
videoErrorCallback: function (e) { videoErrorCallback: function(e) {
console.log(e.target.errMsg);
uni.showModal({ uni.showModal({
content:e.target.errMsg, content: e.target.errMsg,
showCancel:false showCancel: false
}) })
}, },
getRandomColor: function () { getRandomColor: function() {
const rgb = [] const rgb = []
for (let i = 0; i < 3; ++i) { for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16) let color = Math.floor(Math.random() * 256).toString(16)
...@@ -78,5 +74,7 @@ ...@@ -78,5 +74,7 @@
</script> </script>
<style> <style>
video{width:690upx;} video {
</style> width: 690upx;
\ No newline at end of file }
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册