复制了demo的代码,只是换了播放地址
<template>
<view>
<view class="uni-padding-wrap uni-common-mt">
<view>
<video id="myVideo" :src="src"
controls :poster="poster"></video>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '附件',
src: '',
poster:'',
danmuList: [{
text: '第 1s 出现的弹幕',
color: '#ff0000',
time: 1
},
{
text: '第 3s 出现的弹幕',
color: '#ff00ff',
time: 3
}
],
danmuValue: ''
}
},
onReady: function(res) {
// #ifndef MP-ALIPAY
this.videoContext = uni.createVideoContext('myVideo')
// #endif
},
onLoad() {
let video = this.$storageSyncUtil.getVideoSrc();
this.src=video.link;
this.poster=video.iamge;
},
methods: {
sendDanmu: function() {
this.videoContext.sendDanmu({
text: this.danmuValue,
color: this.getRandomColor()
});
this.danmuValue = '';
},
getRandomColor: function() {
const rgb = []
for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16)
color = color.length == 1 ? '0' + color : color
rgb.push(color)
}
return '#' + rgb.join('')
}
}
}
</script>
<style>
video {
width: 690upx;
}
</style>
0 个回复