bytedance / xgplayer

A HTML5 video player with a parser that saves traffic
https://h5player.bytedance.com/
MIT License
7.99k stars 843 forks source link

如何异步加载弹幕 #1478

Open gkj17 opened 1 month ago

gkj17 commented 1 month ago

您使用的西瓜播放器版本是多少? What version of xgplayer are you using? 3.0.15

您使用的操作系统和浏览器分别是? What OS and browser are you using? 感觉和环境无关系

如何复现问题? How to reproduce the problem? 弹幕数据有十几万条,第一次同步去请求弹幕然后再播放视频的话,会有点久,想的是先播放视频,然后异步加载弹幕(但不是一直掉调用sendDanmu....),有什么方法吗?

您期望的播放器正常行为是? What did you expect to happen?

实际播放器的表现是? What actually happened?

可填写您所在的公司和相关产品业务,方便我们提供更好的技术支持 You can write your company and product which uses xgplayer, for helping us provide better technical support.

gemxx commented 3 weeks ago

@gkj17 目前弹幕SDK共有两个接口可以为其提供,sendDanmu & updateComments。我想你是想问有没有可以批量更新数据的接口 单条:sendDanmu,适合用户主动发布弹幕场景 批量:updateComments,适合通过数据源,批量设置给弹幕SDK

// 批量更新弹幕数据,适合在从接口中获取到批量数据时调用
danmu.updateComments([
  {
    duration: 15000,
    id: 'id',
    start: 3000, //不提供该项则立即发送
    txt: '弹幕内容',
  },
  ...
])