search
HomeWeb Front-endHTML TutorialWebsite background music implementation method_HTML/Xhtml_Web page production

For individual webmasters, how to make their website unique and full of personality has always been the goal of unremitting efforts. In addition to improving the visual effects and interactive functions of the page as much as possible, if you can hear a beautiful and moving music while opening the web page, I believe this will make your website more colorful.

 1. Learn to add music files

There are generally two ways to add background music to a web page. The first is to add it through the ordinary tag , the other is to add it through the tag.

  (1) Use the tag

Use Dreamweaver to open the page where you need to add background music, click "Code" to open the code editing view, and click on the and select bgsound in the pop-up code prompt box (Figure 1).


Dreamweaver automatically enters the "
 

 Among them, loop="-1" means that the music plays in an infinite loop. If If you want to set the number of plays, just change it to the corresponding number.

This method of adding background music is the most basic method and the most commonly used method. The background music format supports most of the current mainstream music formats, such as WAV, MID, MP3, etc. If you want to take into account browsers with low Internet speeds, you can use MID sound effects as background music for web pages. Because MID music files are small, they can be loaded and played quickly when the web page is opened. However, MID also has shortcomings. It can only store the melody of music, but does not have nice harmonies or lyrics. If your Internet speed is fast, or you feel that MID music is a bit monotonous, you can also add MP3 music. Just change happy.mid in the above code to happy.mp3.

Tip: Adding background music to FrontPage is more convenient than Dreamweaver. Just make relevant settings in the "Background" dialog box (Figure 2).


  (2) Use the tag

The method of using the tag to add music is not very common, but its function is very powerful, if combined with some Playback controls can create a Web player.

Its use method is basically the same as the first one, except that in the first step of the code prompt box, do not select gbsound, select embed instead. Then select its attributes and set them accordingly (Figure 3). It can be seen from the figure that embed has many more attributes than gbsound's five attributes. The final code is as follows: .

Where autostart is used to set whether music will automatically play when the page is opened, and hidden is used to set whether to hide the media player. Because embed is actually similar to a music player on a Web page, if it is not hidden, your system's default media plug-in will be displayed.

Regarding these two methods, the author believes that both have their own advantages and disadvantages: the first method plays music when the page is opened. If the page is minimized, the music will automatically pause after playing. This will not happen with the second method. As long as the window is not closed, it will keep playing. So I hope you can choose the method of adding music according to your own situation during use.

After you have learned the simple method of adding web music, you should work on the interface and functions. We can use "Web Music Player" to create a stylish music player.

2. Create a fashionable music player

After you have learned the simple method of adding web music, you should work on the interface and functions. We can use "Web Music Player" to create a stylish music player.

Tip: "Web Music Player" is a web plug-in. After running the created page, it will call the Windows Media player that comes with the system to play the preset MP3 songs.

 (1) Simple settings

First download the playback plug-in (download address: http://www.jb51.net/jiaoben/32793.html), unzip and enter the directory, where music.htm is the playbar page we want to load on the homepage, list.htm is the pop-up page used by viewers to view the playlist, and the js folder stores several playback pages Control file, img contains some picture files of the playback interface.

Use web editing software to open music.htm and find the following code:

|true
 var blnShowMmInfo =false
 

 Here you can make basic settings for the player. The meanings of the above sentences are: whether to play automatically, whether to play sequentially, whether to display the status bar, whether to display the audio control status, whether to allow the display of playlists, whether to use SMI mode, whether to loop, and whether to display song information. You can set them according to your needs, where true is "yes" and false is "no". In addition, in order to make your playback bar more personalized, you can also find the ... statement in the music.htm code and change the homepage name in it to your own homepage name.

 
(2) Add playlist


Open the playlist file bglist.js in the js folder, where you can add your favorite songs to the list Yes, the specific adding format is mkList "song path" "song description", where the "song path" can be the local address you uploaded to the host, or you can specify the MP3 address on the network, and the "song description" is It is used to scroll and display on the play bar, which can be the name of the artist and the song. For example, to add Jay Chou's "Tornado", we first find the link address that can be played in real time on the Internet, and then add it to the list: mkList "http://202.102.43.37/hy/yinyue/Jay Chou/09. mp3""Jay Chou - Tornado".

 
Tips: In order to keep your homepage music constantly listening and fresh, we can update the playlist at intervals.
 
(3) Install the player

In order to prevent clicking on the homepage link from affecting the continuity of song playback, we need to install the playback page music.htm in the form of a frame Go to the homepage.
Taking FrontPage 2003 as an example, execute "New → Other Web Page Template" to pop up the "Web Page Template" window, select "Frame Web Page → Footer", "OK" and set the initial web page in the upper frame to point to your Home page, point to music.htm in the lower frame, then remove the frame border in the frame properties and adjust the height of the lower frame appropriately (Figure 4). The height of the frame is enough to accommodate the height of the play bar. Once you're satisfied with the preview, you can save the page and point your website to this new page.



Statement
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
Explain the importance of using consistent coding style for HTML tags and attributes.Explain the importance of using consistent coding style for HTML tags and attributes.May 01, 2025 am 12:01 AM

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

How to implement multi-project carousel in Bootstrap 4?How to implement multi-project carousel in Bootstrap 4?Apr 30, 2025 pm 03:24 PM

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How does deepseek official website achieve the effect of penetrating mouse scroll event?How does deepseek official website achieve the effect of penetrating mouse scroll event?Apr 30, 2025 pm 03:21 PM

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

How to modify the playback control style of HTML videoHow to modify the playback control style of HTML videoApr 30, 2025 pm 03:18 PM

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

What problems will be caused by using native select on your phone?What problems will be caused by using native select on your phone?Apr 30, 2025 pm 03:15 PM

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone?What are the disadvantages of using native select on your phone?Apr 30, 2025 pm 03:12 PM

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...

How to optimize collision handling of third-person roaming in a room using Three.js and Octree?How to optimize collision handling of third-person roaming in a room using Three.js and Octree?Apr 30, 2025 pm 03:09 PM

Use Three.js and Octree to optimize collision handling of third-person roaming in the room. Use Octree in Three.js to implement third-person roaming in the room and add collisions...

What problems will you encounter when using native select on your phone?What problems will you encounter when using native select on your phone?Apr 30, 2025 pm 03:06 PM

Issues with native select on mobile phones When developing applications on mobile devices, we often encounter scenarios where users need to make choices. Although native sel...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment