Skip to content

AudioContext.decodeAudioData() fails with 'EncodingError: Decoding failed' error #1513

@leshak2k

Description

@leshak2k

Safari 15 beta 4 @ MacOS Catalina v10.15.7

The following code fails to play mp3 audio file with EncodingError: Decoding failed error:

  loadAudioWithHowler() {
    const audio = new Howl({
      src: 'https://bug2report.s3.amazonaws.com/popup.mp3',
      preload: false,
      html5: false,
    })
      .on('load', () => {
        console.log(`+++ loaded`);
      })
      .on('loaderror', (id, message) => {
        console.log(`+++ error -> ${message}`);
      });

    audio.load();
  }

Corresponding howler.core.js function with added error parameter:

...
  var decodeAudioData = function(arraybuffer, self) {
    // Fire a load error if something broke.
    var error = function(error) {
      self._emit('loaderror', null, `Decoding audio data failed: ${error}`);
    };

    // Load the sound on success.
    var success = function(buffer) {
      if (buffer && self._sounds.length > 0) {
        cache[self._src] = buffer;
        loadSound(self, buffer);
      } else {
        error();
      }
    };

    // Decode the buffer into an audio source.
    if (typeof Promise !== 'undefined' && Howler.ctx.decodeAudioData.length === 1) {
      Howler.ctx.decodeAudioData(arraybuffer).then(success).catch(error);
    } else {
      Howler.ctx.decodeAudioData(arraybuffer, success, error);
    }
  }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions