Support for HTML5 audio: embedded simple sound tips, html5 audio

Source: Internet
Author: User

Support for HTML5 audio: embedded simple sound tips, html5 audio
Learn how to use HTML audio elements to embed sounds in webpages easily. This tutorial contains a large number of sample codes. Up to now, audio playing in Web browsers has been a black art. Traditionally, there are several ways to embed sound in a web page-some work better than others, and many work only, if you happen to use the right browser, use the right plug-in. The ubiquitous Flash plug-in has helped a lot, because Flash can easily embed audio into most browsers. However, this does not help iPhone and iPad do not support Flash browsers, such as Safari. In short, this is a bit messy. Fortunately, HTML5 seems to make life easier for our developers due to their audio elements. This element allows you to embed audio files in a webpage and control the playing sound using JavaScript. More importantly, it does not require any plug-ins and supports almost all modern Web browsers. (We will return to the browser support !) In this tutorial, I will show you how to embed audio elements into a page. Let's also look at how to trigger and stop audio via JavaScript, and how to ensure that our audio can play many Web browsers. The basic audio elements of HTML5 audio are easy to use. Since this season is happy-and Europe's more than its fair share of the snow-Let's embed short MP3 clips into the "White Christmas" of petabus Bay <audio src = "whitechristmascript"> </audio> // www.heatpress123.net does not have much explanation, it must be here !, Just as the tag allows you to include an image file on a page, the <AUDIO> tag includes an AUDIO file. Cross-browser support is simple, but in the above example, it will not work normally in many browsers. This is an audio file format Thermal Transfer Machine. Some browsers can play MP3 files but not OGG files, while others can play files in OGG format, but no. MP3. Most browsers can play WAV files. WAV files are decompressed, resulting in large file sizes. this is anything other than unrealistic Short audio clips. The following briefly introduces that the current browser supports multiple audio formats:

 

Browser . MP3 . OGG . Wav
Firefox 4 No Yes Yes
Safari 5 Yes No Yes
Chrome 8 Yes Yes Yes
Opera 11 No Yes Yes
IE9 Yes No Yes

 

Which audio formats does your browser support. From the table, we can see that the only feasible method is to provide a cross-browser that supports the audio playback service, which can play MP3 files and OGG files to other files. To do this, you can add multiple <source> <AUDIO> elements to specify multiple AUDIO files in the same format. Then, the browser will play the first file, which can be played. The following is an example:
<AUDIO> <source src = "whitechristmascript"> <source src = "WhiteChristmas.ogg"> </audio> Of course, this does not mean that you need to create a file. Audio files of MP3 and OGG versions (for example, the Audacity tool is convenient), but it will provide you with good cross-browser support. Http://html5.662p.com/thread-10-1-1.html
How can I play only one audio in html5?

Use JS
Write in his onplay event
AudioB. onplay = function ()
{
If (! AudioA. paused)
{
AudioA. pause ();
}
}

There are many implementation methods. For the audio API, see www.w3school.com.cn/...om.asp.

How does html5 collect sound?

Collect sound ??

Do you mean the recording sound or something ??!!

Html5 does not have the recording sound function, but it can still be implemented if flash is embedded in js. Please refer to this article:
Www.itlearner.com/article/2414

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.