可以添加一个从头播放的方法吗?
Closed this issue · 2 comments
kuige commented
现在pcm数据全部播放一遍之后,就不能从头播放了,组件内部能否保存接收到的pcm数据,以便支持从头播放,就像 html 的 audio 标签那样
同时添加一个player.replay()
的方法
pkjy commented
工具本身目标是流式播放,更像是打电话的那种场景。你需要重播的话,可以先自己把收到的音频数据存起来,然后按需再次进行播放。
<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 commented
This issue was closed because it has been inactive for 14 days since being marked as stale.