Comments (2)
JS的setTimeout是不block的,就是你这里要是同时收到了多个弹幕,那setTimeout会同时执行,并行的,所以起不到节流的效果。
live.on每次收到弹幕就会立即执行,是一个eventTrigger? js里面经常会碰到,所谓event driven
我个人的一个可能是这样:
let danmu = ''
live.on('DANMU_MSG', data => {
const output = data.info[1]
console.log(output)
danmu = output
})
const wait = ms => new Promise(resolve => setTimeout(resolve, ms))
const tts = async () => {
while (true) {
if (danmu) {
const currentDanmu = danmu
danmu = ''
// read danmu
}
await wait(3000)
}
}
tts()
from bilibili-live-ws.
感谢老哥,已解决。我的方案是在这基础上设置一个proxy,用来响应式触发tts
from bilibili-live-ws.
Related Issues (20)
- 浏览器环境下,使用 Vite 打包时出现错误 HOT 6
- Uncaught (in promise) TypeError: packs.flatMap is not a function HOT 15
- 请教问题 HOT 2
- 请教一下DANMU的数据结构 HOT 3
- 再问个问题 HOT 2
- 关于 【Could not resolve "pako"】 与 【Dynamic require of "buffer" is not supported】的问题 HOT 11
- live.send()具体可以做什么,怎么使用呢。能更新下文档相关内容吗。 HOT 3
- 报错:KeepLiveTCP is not a constructor HOT 4
- mobileRoomInit(短号解析接口)报404 HOT 10
- 可以直接打包成js文件吗?不通过npm引入 HOT 1
- [bug] 有些直播间心跳包只会返回1,并且接收不到数据 HOT 2
- Bug: `Buffer` 未定义 HOT 13
- type为DANMU_MSG的信息里,用户名变成了****,uid和灯牌信息都变成了0 HOT 5
- 弹幕用户名打码功能跟进 HOT 17
- Message structure interface for different events? HOT 2
- 弹幕获取似乎有些问题 HOT 21
- 开放平台要怎么连接? HOT 3
- 关于Online 数字始终为1 的问题 HOT 1
- 需要登录能力 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bilibili-live-ws.