Firefox API audio compatibility issue

5
I'm using the API to issue some sounds, the problem is that in Firefox I can not run mp3 , but how can I do to include other formatting in this code?

How can I do to add another ogg font for example?

I'm using API to call Audio like this:

 var SomDeDigito = new Audio('sounds/keyboard.mp3');
 var SomDeError = new Audio('sounds/erro.mp3');
 var SomDeSky = new Audio('sounds/sky.mp3');
 var SomDeEstrela = new Audio('sounds/estrela.mp3');
 var SomDeSkyFall = new Audio('sounds/skyFall.mp3');

function digito(){
    SomDeDigito.pause();
    SomDeDigito.currentTime = 0;
    SomDeDigito.play();
}
    
asked by anonymous 08.12.2015 / 03:09

2 answers

4

Audio API support in Firefox is currently partial, as you can see on this Mozilla Foundation list :

<audio>: MP3    Firefox (Gecko): Partial (see below)
  To avoid patent issues, support for MPEG 4, H.264, MP3 and AAC is not built directly into Firefox on desktop and mobile (Android and Firefox OS). Instead it relies on support from the OS or hardware (the hardware also needs to support the profile used to encode the video, in the case of MP4).

The Portuguese translation is as follows:

  To avoid patent issues, support for MPEG 4, H.264, MP3 and AAC are not built directly on Firefox desktop and mobile devices (Android and Firefox OS). Instead it has the support of the operating system or hardware (the hardware also needs to be able to support the profile used to encode the video, in the case of MP4).

In your case, it would be advisable to allow the selection of the format to be consumed according to the client - or convert your file base to Ogg Vorbis format, as all modern browsers support this format.

    
08.12.2015 / 03:13
2

Use SoundManager 2, a very good hybrid API, which uses a Flash player when HTML5 is not fully supported.

link

    
08.12.2015 / 04:01