In some language teaching software, often uses the text display and the sound synchronization playback, we may use the Delphi realization.
First, the production of materials
First, we select a few articles, here we choose Martin Luther King, Lincoln and Ronald Reagan's speeches, each article divides into several sentences, when makes the sound file, notes each sentence start time and the end time, then records it in a data table, this table has the following fields: NO, TEXT, StartTime, Represents the ordinal, content, and start time of each sentence.
Second, the production of the interface
Create a new project in Delphi, put multimedia control in form, Rich Text Editor, command button, radio group box, datasheet, clock and label, as shown
Properties of individual controls
1. The AutoEnable and AutoOpen properties of the multimedia control are set to false, and the Visiblebuttons attribute sets the record, Eject, and step as invisible.
2. The table control's databasename is set to the directory where the tables are stored, and we store the application, sound files, and tables in the Myprog directory, so DatabaseName is set to C:\myprog here, Set TableName to the name of the datasheet that corresponds to the default playback file, which is set to EX1.DBF.
3, the caption of the Radiogroup control is set to ' Please select the playback content ', add three lines to the Itmes feature: Martin Luther King, Lincoln, Ronald Reagan.
4, RichEdit control of the lines characteristics plus ' speech content.
Iv. Code Writing
1. Variable declaration
var isend:Boolean;
CurrentButton:TMPBtnType;
CurrentPlay,CurrentDisp:longint;
Where isend indicates whether playback has been to the end, Currentbutton indicates which button is pressed in the current MediaPlayer component, Currentplay, Currentdisp represents the current playback record and the current display record.
2, in the Formcreate incident to do some necessary preparatory work, the code is as follows:
procedure TForm1.FormCreate(Sender: TObject);
begin
Table1.TableName:=ex1.dbf; Table1.Open;
MediaPlayer1.FileName:=ex1.wav;MediaPlayer1.Open;
MediaPlayer1.TimeFormat:=tfMilliseconds;
isend:=False;
CurrentButton:=btStop;
CurrentDisp:=1;
CurrentPlay:=1;
end;