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

How to use the browser plug-in to play audio in HTML

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

Share

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

This article is about how to use browser plug-ins to play audio in HTML. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

HTML Audio

There are many ways to play sound in HTML.

Use plug-ins

The browser plug-in is a minicomputer program that extends the standard functionality of the browser.

Plug-ins have many uses: playing music, displaying maps, verifying bank accounts, controlling input, and so on.

You can use the or tags to add plug-ins to the HTML page.

These tags define the containers for the resource, and depending on the type, they are displayed both by the browser and by the external plug-in.

Tip: it is a HTML5 tag that is not valid in HTML 4 and the page cannot be validated by HTML 4.

Tip: the HTML5 tag cannot be verified by HTML 4. Use to resolve the verification problem.

Use element

Tags define containers for external (non-HTML) content.

Note: displays the MP3 file embedded in the web page. The browser may need to install the plug-in before playing the file.

Tip: different browsers have different support for audio formats. If the user does not have a plug-in installed, the audio will not be played.

Use element

Tags can also define containers for external (non-HTML) content.

Use the HTML5 element

Element is a HTML5 element that is illegal in HTML 4 but is valid in all browsers.

Your browser does not support this audio format.

Note: this example uses a mp3 file

It is valid in Internet Explorer, Chrome, and Safari.

To make this audio valid in both Firefox and Opera, a file of type ogg has been added.

If it fails, an error message is displayed.

The best HTML solution

Note: two different audio formats are used.

The HTML5 element attempts to play the audio in mp3 or ogg.

If it fails, the code rolls back the attempt element.

Yahoo Media player

Using Yahoo Media player is a different way to add audio to web pages. It can play mp3 and a range of other formats.

With a simple line of code, you can add it to a web page, easily turning a HTML page into a professional playlist.

Play Sound

It is free to use the Yahoo player. To use it, you need to insert this JavaScript at the bottom of the page:

Then simply link the MP3 file to your HTML, and JavaScript will automatically create a play button for each song:

Play Song 1Play Song 2Play Song 3Play Song 4Play Song 5

Yahoo Media player provides your users with a small play button, not a full player.

However, when you click the button, the full player pops up.

Notice that the player is always docked at the bottom of the window frame. Just click on it and slide it out.

Use hyperlinks

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

Play the sound

Note: if the user clicks on the link, the browser will launch the Auxiliary Application to play the file.

The voice of inline

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.

HTML 4.01 Multimedia label and description

Do not approve of using it. Define an embedded applet.

It is not recommended in HTML4, but is allowed in HTML5. Define embedded objects.

Define an embedded object

Defines the parameters of the object

HTML 5 Multimedia tags and descriptions

Tags define sounds, such as music or other audio streams

Tags define embedded content, such as plug-ins

Thank you for reading! This is the end of this article on "how to use browser plug-ins to play audio in HTML". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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