Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以添加一个从头播放的方法吗? #14

Closed
kuige opened this issue Jan 9, 2024 · 2 comments
Closed

可以添加一个从头播放的方法吗? #14

kuige opened this issue Jan 9, 2024 · 2 comments

Comments

@kuige
Copy link

kuige commented Jan 9, 2024

现在pcm数据全部播放一遍之后,就不能从头播放了,组件内部能否保存接收到的pcm数据,以便支持从头播放,就像 html 的 audio 标签那样

同时添加一个player.replay()的方法

@pkjy
Copy link
Owner

pkjy commented Jan 10, 2024

工具本身目标是流式播放,更像是打电话的那种场景。你需要重播的话,可以先自己把收到的音频数据存起来,然后按需再次进行播放。

<button onclick="replay()">重放</button>
// 伪代码
let box = []
ws.addEventListener('message', function (event) {
    // 拿到数据的时候,缓存一份
    box.push(event.data)
});

function replay(){
  let count = 0
  setInterval(()=>{
    player.feed(box[count]);
    count++
  },200)
}

@pkjy
Copy link
Owner

pkjy commented May 25, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@pkjy pkjy closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants