Add background music on the webpage

Source: Internet
Author: User
Add background music on the webpage

I. Learn to add music files

There are two methods to add background music to a webpage. The first method is to add background music by using the <bgsound> label, and the other is to add background music by using the <embed> label.

(1) Use the <bgsound> label

Use Dreamweaver to open the page for adding background music, click "code" to open the code editing view, and enter "<" between <body> </body>? We are always aware of gsound.
After Dreamweaver automatically enters the <bgsound "code, press the Space key. The code prompt box automatically lists the properties of the bgsound label for your choice. The bgsound tag has five attributes. Among them, balance sets the Left and Right balancing of music, delay sets the playback latency, loop controls the number of loops, and src is the path of our music file, volume is the volume setting. Generally, when adding background music, we do not need to set the Left and Right balancing and latency of the music, so we only need a few major parameters. The final code is as follows:

<Bgsound src = "music. mid" loop = "-1">

Loop = "-1" indicates infinite loop playback of music. If you want to set the number of playback times, change it to a number.

This method is the most basic and commonly used method to add background music. It supports most mainstream music formats, for example, WAV, MID, and MP3. If you want to take into account low-speed viewers, you can use the MID sound effect as the background music of the webpage. Because the MID music file is small, it can be quickly loaded and played during the webpage opening process, however, there are also deficiencies in MID. It can only store Music Melody, without sound and lyrics. If your network speed is fast or you think MID music is monotonous, you can also add MP3 music. You only need to change the "happy.mid" in the preceding code to" happytasks.

Tip: Adding background music to FrontPage is more convenient than Dreamweaver. You only need to set it in the background dialog box.

(2) Use the <embed> label

It is not very common to use the <embed> label to add music, but it is very powerful. If you use some playback controls, you can create a Web player.

Its usage is basically the same as that of the first one, but do not select gbsound in the code prompt box in the first step. Select embed instead. Then select its attributes for corresponding settings. It can be seen that the attributes of embed are much more than those of the five attributes of gbsound. The final code is as follows: <embed src = "musicloud" autostart = "true" loop = "true" hidden = "true"> </embed>.
Autostart is used to set whether the music is automatically played when the page is opened, while hidden sets whether to hide the media player. Because embed is actually similar to a webpage music player, if it is not hidden, it will display the default media plug-in of your system.

The two methods have their own advantages and disadvantages. The first method is to play music when the page is opened. If the page is minimized, the concert will be automatically paused, if you use the second method, this will not happen. As long as you do not close the window, it will continue playing. Therefore, we hope that you can choose to add music based on your needs.

After learning the simple method of adding webpage music, you should work on the interface and functions. We can use web music player to create a fashionable music player. I. Learn to add music files

There are two methods to add background music to a webpage. The first method is to add background music by using the <bgsound> label, and the other is to add background music by using the <embed> label.

(1) Use the <bgsound> label

Use Dreamweaver to open the page for adding background music, and click "code" to open the code editing view, enter "<" between <body> </body> and select bgsound in the pop-up code prompt box.
After Dreamweaver automatically enters the <bgsound "code, press the Space key. The code prompt box automatically lists the properties of the bgsound label for your choice. The bgsound tag has five attributes. Among them, balance sets the Left and Right balancing of music, delay sets the playback latency, loop controls the number of loops, and src is the path of our music file, volume is the volume setting. Generally, when adding background music, we do not need to set the Left and Right balancing and latency of the music, so we only need a few major parameters. The final code is as follows:

<Bgsound src = "music. mid" loop = "-1">

Loop = "-1" indicates infinite loop playback of music. If you want to set the number of playback times, change it to a number.

This method is the most basic and commonly used method to add background music. It supports most mainstream music formats, for example, WAV, MID, and MP3. If you want to take into account low-speed viewers, you can use the MID sound effect as the background music of the webpage. Because the MID music file is small, it can be quickly loaded and played during the webpage opening process, however, there are also deficiencies in MID. It can only store Music Melody, without sound and lyrics. If your network speed is fast or you think MID music is monotonous, you can also add MP3 music. You only need to change the "happy.mid" in the preceding code to" happytasks.

Tip: Adding background music to FrontPage is more convenient than Dreamweaver. You only need to set it in the background dialog box.

(2) Use the <embed> label

It is not very common to use the <embed> label to add music, but it is very powerful. If you use some playback controls, you can create a Web player.

Its usage is basically the same as that of the first one, but do not select gbsound in the code prompt box in the first step. Select embed instead. Then select its attributes for corresponding settings. It can be seen that the attributes of embed are much more than those of the five attributes of gbsound. The final code is as follows: <embed src = "musicloud" autostart = "true" loop = "true" hidden = "true"> </embed>.
Reference: http://publishblog.blogchina.com/blog/tb. B? DiaryID = 4226731

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.