Example of adding music video to HTML page

Example of adding music video to HTML page

1. Video tag

Supports automatic playback in Firefox, but not in Google and IE

<video controls="controls" autoplay="autoplay" name="media"><source src="./img/music.mp3" type="audio/mpeg"></video>

Google can enable autoplay by adding muted

<video controls="controls" autoplay="autoplay" name="media" muted><source src="./img/music.mp3" type="audio/mpeg"></video> 

The principle is that most browsers support silent video playback.

<video controls="controls" autoplay="autoplay" name="media" muted><source src="http://vjs.zencdn.net/v/oceans.mp4" type="audio/mpeg"></video>

2. Audio tag

Note: The tag defines a sound, such as music or other audio stream.

<audio controls="controls" ><source src="./img/music.mp3"></audio> 

Note: Only music can be loaded, not video

3.embed

Supports multiple players

Autoplay supports Android, but not iOS. It supports Google IE and Edge, but not Firefox.

<embed src="./img/music.mp3" hidden="true" autostart="true" loop="true"> 
<embed src="http://vjs.zencdn.net/v/oceans.mp4" autostart="true" loop="true"> 

Additional notes:

It has always been a common practice on iOS and Android that audio cannot be played automatically. The desktop version of Safari also announced in version 11 in 2017 that it would disable the automatic playback of multimedia with sound. Then, Chrome 66 released in April 2018 also officially turned off the automatic playback of sound, which means that <audio autopaly> <video autoplay> will also be invalid on the desktop version of the browser.

Google explains:
Exception conditions for automatic playback: As mentioned above, if the video itself has been set to mute, the browser will no longer block its loading for automatic playback. At the same time, if the user has clicked on auto-play before, the browser will not block the playback by default when visiting the same website next time. On mobile devices, if the user chooses to add the website to the home screen, that is, the website that is frequently visited, it can also be played automatically in this case.
Finally: According to Google statistics, if the website video is played in large quantities, such as video websites, the automatic play function will not be blocked in this case

This is the end of this article about the implementation example of adding music videos to HTML web pages. For more relevant content about adding music videos to HTML, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future!

<<:  Implementation of MySQL Multi-version Concurrency Control MVCC

>>:  Rainbow button style made with CSS3

Recommend

Summary of methods to include file contents in HTML files

In the forum, netizens often ask, can I read the ...

Full HTML of the upload form with image preview

The upload form with image preview function, the ...

mysql5.7.21.zip installation tutorial

The detailed installation process of mysql5.7.21 ...

JS Canvas interface and animation effects

Table of contents Overview Canvas API: Drawing Gr...

HTML 5 Reset Stylesheet

This CSS reset is modified based on Eric Meyers...

Learn Hyperlink A Tag

ask: I have styled the hyperlink using CSS, but i...

How to quickly query 10 million records in Mysql

Table of contents Normal paging query How to opti...

Javascript to achieve drumming effect

This article shares the specific code of Javascri...

A complete tutorial on installing Ubuntu 20.04 using VMware virtual machine

Ubuntu is a relatively popular Linux desktop syst...

Use of Linux read command

1. Command Introduction The read command is a bui...