Text/Lonely Smile Falling in Love with a Fish
For individual webmasters, how to make their websites 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 <bgsound> tag, and the other is to add it through the <embed> tag.
(1) Use the <bgsound> tag
to open the page where you need to add background music with Dreamweaver, click "Code" to open the code editing view, enter "<" between <body>< /body> and select bgsound in the pop-up code prompt box (Figure 1).
Figure 1
Dreamweaver automatically enters the "< bgsound" code and press the space bar. The code prompt box will automatically list the attributes of the bgsound tag for you to choose and use. The bgsound tag has five attributes. Balance is to set the left and right balance of the music, delay is to set the playback delay, loop is to control the number of loops, src is the path to our music file, and volume is the volume setting. Generally when adding background music, we do not need to set the left and right equalization and delay settings for 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 the music plays in an infinite loop. If you want to set the number of playback times, 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 the background music of 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 relatively more convenient than Dreamweaver. Just make relevant settings in the "Background" dialog box (Figure 2).
Figure 2
(2) Using the <embed> tag
It is not very common to use the <embed> tag to add music, but its function is very powerful. If combined with some playback controls, a Web player can be created.
Its usage is basically the same as the first one, except that in the first step of the code prompt box, do not select gbsound, but 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: < embed src="music.mp3" autostart="true" loop="true" hidden="true"></embed>.
Figure 3,
autostart is used to set whether music plays automatically when the page is opened, and hidden sets 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.
For 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 and then played, the music will automatically pause. If the second method is used, it will not When this happens, it will continue to play as long as the window is not closed. 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: "Webpage Music Player" is a webpage 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.mh.fy.cn/soft/music.rar), unzip and enter the directory, where music.htm is the playback we want to load on the homepage page, list.htm is a pop-up page for viewers to view playlists, the js folder contains several playback control files, and img contains some image files for the playback interface.
Use web page 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 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 <marquee>......< /marquee> statement in the music.htm code and change the homepage name in it to the name of your own homepage .
(2) Add playlist
Open the playlist file bglist.js in the js folder. Here you can add your favorite songs to the list. 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. The "song description" is used to scroll and display on the play bar, and can be the name of the artist and 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 the music on your homepage always fresh and new, 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 on the homepage in the form of a frame.
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, and in the lower frame. Point to music.htm, then remove the frame border in the frame properties and adjust the height of the 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.
Figure 4