Jump to content

Handle sound effects to work on all browsers?


toto88x
 Share

Recommended Posts

Hi,

 

I've read that wav files do not work on Internet Explorer browser. Is that true?

If so, how do you handle sound effects to work on all browsers then?

 

Is there a way to tell Phaser something like that:

- Play wav sounds when browser != IE

- Play mp3 sounds when browser == IE

 

Thanks!

Link to comment
Share on other sites

The audio loader accepts multiple formats for a single sound by passing an array of strings containing the locations of the files. If you encode your sounds to mp3 and ogg vorbis (links to very simple free drag and drop encoders) you can pass these files into the loader like so:

game.load.audio('sfx', [ 'assets/audio/sfx.mp3', 'assets/audio/sfx.ogg' ]);

I've not encountered any modern browsers which lack support for both of these formats, and both are preferable to wav in terms of file size alone, usually in the order of at least a tenth the size.

Link to comment
Share on other sites

The audio loader accepts multiple formats for a single sound by passing an array of strings containing the locations of the files. If you encode your sounds to mp3 and ogg vorbis (links to very simple free drag and drop encoders) you can pass these files into the loader like so:

game.load.audio('sfx', [ 'assets/audio/sfx.mp3', 'assets/audio/sfx.ogg' ]);

I've not encountered any modern browsers which lack support for both of these formats, and both are preferable to wav in terms of file size alone, usually in the order of at least a tenth the size.

 

Wow I didn't know that, it's really nice! And then Phaser will automatically play the correct file by just doing "sound.play();" ?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...