mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -05:00
Handle empty sounds
This commit is contained in:
parent
0ee5fb95c3
commit
6f32a0bec7
1 changed files with 5 additions and 0 deletions
|
@ -154,6 +154,11 @@ class AudioEngine {
|
||||||
// decoder If that fails, attempt to decode as ADPCM
|
// decoder If that fails, attempt to decode as ADPCM
|
||||||
const decoding = decodeAudioData(this.audioContext, bufferCopy1)
|
const decoding = decodeAudioData(this.audioContext, bufferCopy1)
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
// If the file is empty, create an empty sound
|
||||||
|
if (sound.data.length === 0) {
|
||||||
|
return Promise.resolve(this.audioContext.createBuffer(1, 1, this.audioContext.sampleRate));
|
||||||
|
}
|
||||||
|
|
||||||
// The audio context failed to parse the sound data
|
// The audio context failed to parse the sound data
|
||||||
// we gave it, so try to decode as 'adpcm'
|
// we gave it, so try to decode as 'adpcm'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue