通过 setTimeout 连续调用 sendDanmu 发送弹幕,安卓手机会随机丢失弹幕?
安卓手机上的弹幕会随机丢失,无法显示完全。 IOS则没有这样的问题。 代码片段 机型:小米9 系统:MIUI 10.2.25 微信版本:7.0.7 代码示例 index.js [代码]const app = getApp()[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]list: [[代码][代码] [代码][代码]{[代码][代码] [代码][代码]c: 1,[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]c: 2,[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]c: 3,[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]c: 4,[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]c: 5,[代码][代码] [代码][代码]}[代码][代码] [代码][代码]][代码][代码] [代码][代码]},[代码][代码] [代码][代码]start(){[代码][代码] [代码][代码]const video = wx.createVideoContext([代码][代码]'myVideo'[代码][代码]);[代码][代码] [代码][代码]this[代码][代码].send(video, [代码][代码]this[代码][代码].data.list);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]send(video,list){[代码][代码] [代码][代码]if[代码] [代码](!list.length) {[代码][代码] [代码][代码]return[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]setTimeout(() => {[代码][代码] [代码][代码]const item = list.shift();[代码][代码] [代码][代码]const text = item.c;[代码][代码] [代码][代码]video.sendDanmu({[代码][代码] [代码][代码]text,[代码][代码] [代码][代码]color: [代码][代码]'#666666'[代码][代码],[代码][代码] [代码][代码]});[代码][代码] [代码][代码]this[代码][代码].send(video, list);[代码][代码] [代码][代码]}, 450);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码] [代码] [代码][代码]},[代码][代码]})[代码] 代码示例 index.wxml [代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"intro"[代码][代码]>[代码][代码]<[代码][代码]video[代码][代码] id[代码][代码]=[代码][代码]"myVideo"[代码] [代码] src[代码][代码]=[代码][代码]"http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"[代码] [代码] enable-danmu [代码][代码] danmu-btn[代码][代码] bindplay[代码][代码]=[代码][代码]"start" [代码][代码] controls>[代码] [代码] </[代码][代码]video[代码][代码]>[代码] [代码]</[代码][代码]view[代码][代码]>[代码]