This article mainly introduces how to use jQuery to design a simple web music player instance, including the implementation of basic functions such as the PHP background and reading tracks from MySQL. For more information, see
I. Prepare a database
First, we design the MYSQL database as follows:
CREATE TABLE `songs` ( `song_id` int(11) NOT NULL AUTO_INCREMENT, `url` varchar(500) NOT NULL, `artist` varchar(250) NOT NULL, `title` varchar(250) NOT NULL, PRIMARY KEY (`song_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
Here, the url field indicates the address where mp3 music is stored, artist is the Song artist, and title is the song name. Let's add some sample data, as shown below:
INSERT INTO `songs` (`song_id`, `url`, `artist`, `title`) VALUES ('', 'http://mysongs.com/songurl.mp3', 'Artist name', 'Song name');INSERT INTO `songs` (`song_id`, `url`, `artist`, `title`) VALUES ('', 'http://mysongs.com/anothersongurl.mp3', 'Another artist', 'Another song');INSERT INTO `songs` (`song_id`, `url`, `artist`, `title`) VALUES ('', 'http://mysongs.com/onemoresongurl.mp3', 'One more artist', 'One more song');
2. Design HTML pages
After designing the database, we can design the HTML page. Here we first need to download a music player plug-in jPlayer (http://jplayer.org/) for jQuery /). Decompress the downloaded package and put the content of the js and skin folders under the root directory of your application. They are the javascript files and CSS style application files to be used. Now you can open the HTML page and name it demo.html. The Code is as follows:
Online radio using jQuery