toto88x Posted June 8, 2014 Share Posted June 8, 2014 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 More sharing options...
lewster32 Posted June 8, 2014 Share Posted June 8, 2014 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 More sharing options...
toto88x Posted June 8, 2014 Author Share Posted June 8, 2014 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 More sharing options...
lewster32 Posted June 8, 2014 Share Posted June 8, 2014 That's correct. It'll load and decode the file needed for that browser automatically, and play it when called. Link to comment Share on other sites More sharing options...
j0hnskot Posted June 8, 2014 Share Posted June 8, 2014 In case the browser supports every format of those i put there, will it load and encode every of them? Or will stop if it finds one working? Link to comment Share on other sites More sharing options...
lewster32 Posted June 8, 2014 Share Posted June 8, 2014 I don't know; I'd assume it'd be smart enough to only load and decode the first file it can use. If it doesn't work this way I'd be quite surprised. Link to comment Share on other sites More sharing options...
Recommended Posts