Delphi 3.0 is a very excellent software that makes it easy to make a simple MP3 music point.
Principle: Making an MP3 player (this article is the case of WinPlay3 as an example), establish the relationship between Chinese song name and MP3 file, so that Chinese song name is "song".
step:
First, create a new file
Create a new project and a blank form (Form1), change the Form1's Caption property to "My Cotive", add two COMOBOX components in Form1, one to display the album where the song is located. Change its name attribute to zj, one to display the Chinese song name, change its Name property to GQ, add a Label component to each of them, change its CAPTION attribute to "Album Selection" and "Song Selection", Add two BitBotton components, set their CAPTION attributes to "Play" and "Exit".
Second, observe the characteristics of the CD with MP3 files
The general directory is very regular, such as a copy of the author as an example, a total of 12 albums all over a total of: C01, C02 ... C12, respectively, respectively, named c01.txt, c02.txt ... ... c12.txt text file, enter the Chinese song name under the corresponding album in order, pay attention to a song name, and put it in the current directory. In Object Inspector, select ZJ, double-click its Lines property, then enter the album name, pay attention to a album name to occupy a line; select GQ, double-click its Lines property to delete the default content.
Third, write a program
Add a line of FMXUTILS in Unit1? PAS, add a line in the VAR section:
VAR name: string, path; {name is the file name of the MP3 file, Path is its path}
Then in the Form1 form, double-click ZJ and add the following procedure:
PROCEDURE TFORM1? ZJChange (Sender: TOBJECT);
Begin
Case zj? ItemIndex of
0 ?? 8, 10 ?? 20: path: = 'E: / c0' INTOSTR (zj? Itemindex 1);
9: path: = 'E: / C' ITTOSTR (zj? Itemindex 1);
{E is the drive letter of the optical drive, according to the actual situation}
END;
Name: = ITTOSTR (zj? itemindex) 'txt';
GQ? Items? loadFrom (name);
GQ? text: = GQ? Items? strings [0];
END;
{Double-click the button "Play" button to add the following}
PROCEDURE TFORM1? Button1Click (Sender: TOBJECT);
Begin
Case GQ? ItemIndex of
0 ?? 8, 10 ?? 20: name: = PATH '/' '0' INTOSTR (GQ? ItemInDex 1) `mp3`;
9: name: = PATH '/ 10? MP3';
Else
Name: = PATH 01? MP3 ';
END;
Execute ('WinPlay3? EXE', MPNAME, 'C: / WinPlay3', SW_HIDE);
{WinPlay3? EXE is the file name of the MP3 player, C: / WinPlay is its path, sw_hide is represented as a background, and it is necessary to flexibly determine according to the actual situation. } END;
{Double-click the CAPTION property button to "Close", enter the following}
PROCEDURE TFORM1? Button1Click (Sender: TOBJECT);
Begin
Form1? close;
END;
Fourth, compile operation
Click the RUN icon, the program is compiled and run. At this point, click the "Album Select" drop-down box, which will appear for you to choose from. At the same time, there will be Chinese names in all songs in the "Song Selection". After selecting it, click the "Play" button to play the song. In this way, a simple "point song" is successful.