For individual webmasters, how to make their website unique and full of personality has always been the goal of unremitting efforts. In addition to trying to improve the visual effects and interactive functions of the page, if you can hear a beautiful and moving music while opening the web page, I believe this will add a lot of color to your website.
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 <bgsound> tag, and the other is to add it through the <embed> tag.
(I) Use the <bgsound> tag
Use Dreamweaver to open the page where background music needs to be added, click the code to open the code editing view, enter < between <body></body> and select bgsound in the pop-up code prompt box (Figure 1).
Dreamweaver automatically enters the <bgsound code and press the space bar. The code prompt box will automatically list the properties of the bgsound tag for you to choose from. There are five attributes in the bgsound tag, where balance is to set the left and right balance of music, delay is to set the playback delay, loop is to control the number of loops, src is the path of our music file, and volume is the volume setting. Generally, when adding background music, we do not need to balance the left and right and delay the music, so we only need a few main parameters. The final code is as follows:
<bgsound src=music.mid loop=-1>
Among them, loop=-1 means that music is played infinitely. If you want to set the number of plays, change it to the corresponding number.
This method of adding background music is the most basic method and the most commonly used method. The format of background music supports most mainstream music formats now, such as WAV, MID, MP3, etc. If you want to consider viewers with lower internet speeds, you can use MID sound effects as the background music of the web page, because the MID music file is small, so it can be loaded and played quickly during the web page opening. However, MID also has shortcomings. It can only store the melody of the music, without good harmony and lyrics. If you have a fast internet speed or feel that MID music is a bit monotonous, you can also add MP3 music. Just change the happy.mid in the above code to happy.mp3.
Tip: It is relatively convenient to add background music to FrontPage than Dreamweaver. Just make relevant settings in the background dialog box (Figure 2).
(II) Use the <embed> tag
The method of adding music using the <embed> tag is not very common, but it is very powerful. If you combine some playback controls, you can create a web player.
Its usage is basically the same as the first one, except that in the code prompt box of the first step, do not select gbsound, but instead select embed. Then select its properties for corresponding settings (Figure 3). From the figure, it can be seen that the properties of embed are much more than the five properties of gbsound. The final code is as follows: <embed src=music.mp3 autostart=true loop=true hidden=true></embed>.
autostart is used to set whether the music is automatically played when opening the page, while hidden sets whether the media player is hidden. Because embed is actually similar to a web page music player, if it is not hidden, it will display the default media plug-in of your system.
For these two methods, the author believes that both have advantages and disadvantages: the first method plays music when the page is open, and if the page is minimized, the music will be automatically paused. If the second method is used, this will not happen. As long as the window is not closed, it will keep playing. So I hope everyone will choose the method of adding music according to their own situation during the application process.
After learning the simple method of adding web music, you should put some effort into the interface and functions. We can use "Web Music Player" to create a stylish music player.
2. Create a fashionable music player After learning the simple method of adding web music, you should put some effort into 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 system's own Windows Media Player to play pre-set MP3 songs.
(I) Simple Setting
First, download the playback plug-in (download address: https://www.VeVb.com/jiaoben/32793.html), unzip it and enter the directory. Music.htm is the playback page we want to load on the homepage. List.htm is the pop-up page used by the viewer to view the playlist. The js folder contains several playback control files, and img is some picture files for the playback interface.
Use web editing software to open music.htm and find the following code:
<script Language=Javascript>
var blnAutoStart = true
var blnRndPlay = false
var blnStatusBar = false
var blnShowVolCtrl = true
var blnShowPlist = true
var blnUseSmi = false
var blnLoopTrk = true
var blnShowMmInfo =false
</script>
Here you can make basic settings for the player. The meaning of the above sentences is: whether to play automatically, whether to play sequentially, whether to display the status bar, whether to display the sound control status, whether to allow the display of the playlist, whether to use SMI mode, whether to play 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 <marquee> ....</marquee> statement in the music.htm code and modify the homepage name to the name of your own homepage.
(II) Add a playlist
Open the playlist file bglist.js in the js folder, and you can add your favorite songs to the list. The specific addition 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. The song description is used to scroll to display on the playbar, which can be the name of the singer 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.
Tip: In order to keep your homepage music constantly listening and constantly new, we can update the playlist once a while.
(III) 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 on the homepage in a frame form.
Taking FrontPage 2003 as an example, perform the new → other web templates to pop up the web template window, select the frame web page → footer, and then set the initial web page in the upper frame to point to your home page, and the lower frame points to music.htm, then remove the frame border in the frame properties and adjust the height of the lower frame appropriately (Figure 4). The frame height is enough to accommodate the height of the playbar. After you are satisfied with the preview, you can save the page and point your website to this new page.