<view>
<view class="uni-padding-wrap uni-common-mt">
<view>
<video id="myVideo" :autoplay="true" src="https://mp4.vjshi.com/2018-12-28/1083f3db90334f86e3fc3586b4472914.mp4"
@error="videoErrorCallback" :danmu-list="danmuList" enable-danmu danmu-btn controls></video>
</view>
<!-- #ifndef MP-ALIPAY -->
<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 v-model="danmuValue" class="uni-input" type="text" placeholder="在此处输入弹幕内容" />
</view>
</view>
</view>
<view class="uni-btn-v">
<button @click="sendDanmu" class="page-body-button">发送弹幕</button>
</view>
<!-- #endif -->
</view>
</view>
</template>
<script>
export default {
data() {
return {
src: '',
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
},
methods: {
sendDanmu: function() {
this.videoContext.sendDanmu({
text: this.danmuValue,
color: this.getRandomColor()
});
this.danmuValue = '';
},
videoErrorCallback: function(e) {
// uni.showModal({
// content: e.target.errMsg,
// showCancel: false
// })
console.log(e)
},
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 scoped>
</style>```
- 发布:2020-05-25 18:10
- 更新:2020-05-25 18:10
- 阅读:1522
产品分类: uniapp/H5
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 10.15.3
HBuilderX类型: 正式
HBuilderX版本号: 2.7.7
浏览器平台: 微信内置浏览器
浏览器版本: 7.0.14
项目创建方式: HBuilderX
操作步骤:
预期结果:
wu
wu
实际结果:
点击播放报错
点击播放报错
bug描述:
内置浏览器报错,项目打包到服务器H5视频不播放,手机自带浏览器正常播放,小程序正常,谷歌正常。