Skip to content

Commit

Permalink
fix: exec ctx.createBuffer throw error when audio length is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Nov 22, 2023
1 parent ca206d4 commit 182243a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/av-cliper/demo/decode-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ document.querySelector('#decode-audio')?.addEventListener('click', () => {
// 当前片段的开始播放的时间
let startAt = 0
async function play() {
const { audio, state } = await clip.tick(time)
time += 100000
const { audio, state } = await clip.tick(time)
if (state === 'done') {
console.log('--- ended')
return
}
const len = audio[0].length
if (len === 0) {
play()
return
}

const buf = ctx.createBuffer(2, len, DEFAULT_AUDIO_CONF.sampleRate)
buf.copyToChannel(audio[0], 0)
Expand Down

0 comments on commit 182243a

Please sign in to comment.