The HTML5 Audio tag can support wav, mp3, ogg, acc, webm and other formats, but there is a very important music file format midi (extension mid) that does not have built-in support in major browsers. Not all browsers support MP3 OGG and the like. Each browser supports different formats due to copyright issues.
Browser and audio compatibilityNot all browser manufacturers agree on the use of a certain audio file format. For images, files in PNG, JPEG or GIF format will load into your page on any browser. Unfortunately, this is not the case with audio files. Table 1 shows the audio file formats that can be used in web pages, but not all formats are available in all browsers. For example, Chrome, Internet Explorer 9 (IE9), and Safari browsers do not support WAV files, a declining standard that uses an uncompressed format.
HTML5 browser and audio format compatibilityaudio format | Chrome | Firefox | IE9 | Opera | Safari |
OGG | support | support | support | Not supported | Not supported |
MP3 | support | Not supported | support | Not supported | support |
WAV | Not supported | support | Not supported | support | Not supported |
Not having a common file format that every browser uses means that at least 2/5 browsers will not be able to play certain sounds. This isn't a matter of browser makers being intransigent and unable to agree on a single audio standard, but rather a legal and financial issue involving patent rights and royalties. The OGG format, which is not restricted by software patents, aims to solve this problem once and for all. However, at the time of writing, neither Opera nor Safari support OGG. There are more WAV and MP3 files available than OGG format files, so no doubt browser manufacturers have taken this into consideration. MP3 as the de facto standard is a great solution.
Solution: Use three file types and the <audio> tagGiven the current state of things, you might think that it's not yet prime time for using audio on HTML5 pages. In some ways this may be true, but HTML5 provides a solution that enables your favorite browser to find a compatible format.
When used in conjunction with the <audio> tag, the <source> tag can be nested within an <audio> container. Let's say you're a Wagner fan and want to listen to his opera Ride of the Valkyries on an HTML5 page. First, you need to get music in three file types, namely OGG, MP3, and WAV. Place these music files in the same folder as the HTML5 files. Then, put each file name in a separate <source> tag, and all source tags in the audio container are composed of <audio></audio>, as shown below.
<audio controls> <source src=http://demo.mimvp.com/html5/take_you_fly.ogg /> <source src=http://demo.mimvp.com/html5/take_you_fly.mp3″ /> <source src =http://demo.mimvp.com/html5/take_you_fly.wav /></audio>
No matter what browser your visitor is using, it will automatically select the first file type it reads and play the sound for you.
SummarizeThe above is the solution for audio support audio format in HTML5 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for your support of the VeVb martial arts website!