通过 setTimeout 连续调用 sendDanmu 发送弹幕,安卓手机会随机丢失弹幕?
发布于 5 年前 作者 chaoshi 7716 次浏览 来自 官方Issues

安卓手机上的弹幕会随机丢失,无法显示完全。

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>

1 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部