Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Then use the HTML5 audio element

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces and then uses the HTML5 audio element related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this article and then use the HTML5 audio element article will have a harvest, let's take a look.

The HTML5 element is a HTML5 element that is illegal in HTML4 but valid in all browsers.

Theelementworksinallmodernbrowsers.

Below we will use tags to describe MP3 files (valid in InternetExplorer, Chrome, and Safari), and also add an OGG type file (valid in Firefox and Opera browsers). If it fails, it displays an error text message:

Example

Yourbrowserdoesnotsupportthisaudioformat.

Question:

Tags are not valid in HTML4. Your page cannot be validated by HTML4.

You must convert the audio file to a different format.

Elements do not work in older browsers.

The best HTML solution

The following example uses two different audio formats. The HTML5 element attempts to play the audio in mp3 or ogg. If it fails, the code rolls back the attempt element.

Example

Question:

You must convert the audio to a different format.

The element cannot be rolled back to display an error message.

Use hyperlinks

If a web page contains a hyperlink to a media file, most browsers use Auxiliary applications to play the file.

The following code snippet shows a link to the mp3 file. If the user clicks the link, the browser launches the Auxiliary Application to play the file:

Example

Playthesound

The inline voice indicates

When you include sound in a web page, or as part of a web page, it is called inline sound.

If you plan to use inline sound in your web application, you need to be aware that many people find inline sound exasperating. Also note that the user may have turned off the inline sound option in the browser.

Our best advice is to include them only where users want to hear inline voices. A positive example is that when the user needs to hear the recording and click on a link, the page opens and the recording is played.

This is the end of the article on "then use HTML5 audio elements". Thank you for reading! I believe everyone has a certain understanding of the knowledge of "then use HTML5 audio elements". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report