How to use html5 audio tag? HTML5 autoplay implementation code example

寻∝梦
Release: 2018-08-20 14:14:45
Original
17030 people have browsed it

html5 How to use the audio tag? Tutorial on automatic playback and use of html5 audio tags. Let’s start our article introduction, which mainly introduces the use of html5 audio tags, as well as detailed tutorials on automatic playback and pause of html5 audio tags

html5 audio tags Usage definition:

html5 audio tag example

A simple HTML 5 audio:

Copy after login

Attributes of the html5 audio tag:

How to use html5 audio tag? HTML5 autoplay implementation code example

Let’s give an example tutorial on the use of html5 audio tags

html5 audio tags automatically play and pause

This is a mobile WeChat H5 activity page. One of the requirements is that the background music will automatically start playing after opening the page. Click the music icon button to control its playback and pause.

On the mobile side, for music playback, automatic playback and pause, the audio tag is necessary, so just start writing:

     
Copy after login

How to use html5 audio tag? HTML5 autoplay implementation code example

How to use html5 audio tag? HTML5 autoplay implementation code example

## Simulate on Chrome browser, click on the small speaker, you can synchronously control the audio tag to play and pause, and it can also play automatically.

So I put it on my mobile phone and tested it, and the results came out. . . . .

Everything is normal on the Android phone;

But on the Apple phone, it cannot play automatically when you first enter the page

After checking a lot of information, I found out that this This is because Apple prohibits the automatic playback of audio unless the user actively triggers it in order to prevent the user from being in a traffic environment, which will lead to the theft of traffic. Of course, there are still ways to meet the demand. After all, it is run under someone else's WeChat browser. People have to lower their heads when they are under the eaves!

Another js file introduced by WeChat developers. The overall writing method is as follows: jq and native writing method

    Title    
Copy after login

The difference between HTML 4.01 and HTML 5# The ##

Tips and Notes

Tip: You can place text content between the start tag and the end tag, so that older browsers can display a message that the tag is not supported.

[Related recommendations]

html What is the role of the pre tag? Detailed explanation of the usage of html pre tag and its attributes


What is the HTML li tag used for? Introduction to HTML li tag usage and attributes

The above is the detailed content of How to use html5 audio tag? HTML5 autoplay implementation code example. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!