Mike018

catching audio load errors

Recommended Posts

const filenames = ['test1', 'test2']

forEach(filenames, filename => {
      try {
        this.load.audio(filename, './audio/' + filename + '.mp3')
      } catch (error) {
        console.log('Failed to load:', filename + '.mp3')
      }
    })

Seems this.load.onFileError.add(console.log, this) doesn't work either.

Share this post


Link to post
Share on other sites

Audio loading is an asynchronous process. So the error won't necessarily be thrown from the initial call to this.load.audio, it may be triggered later on. Hence try / catch not working here.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.