Develop and Download Open Source Software

Browse Subversion Repository

Diff of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by yamat0jp, Tue Jul 28 08:41:38 2015 UTC revision 6 by yamat0jp, Sat Aug 1 04:45:13 2015 UTC
# Line 46  type Line 46  type
46      procedure Action4Execute(Sender: TObject);      procedure Action4Execute(Sender: TObject);
47      procedure Action6Execute(Sender: TObject);      procedure Action6Execute(Sender: TObject);
48      procedure Action5Execute(Sender: TObject);      procedure Action5Execute(Sender: TObject);
49        procedure TrackBar2Change(Sender: TObject);
50    private    private
51      { private 宣言 }      { private 宣言 }
52    public    public
53      { public 宣言 }      { public 宣言 }
54      th: TThread;      th: TThread;
55        procedure PlayMusic(Number: integer);
56    end;    end;
57    
58  var  var
# Line 69  begin Line 71  begin
71      MediaPlayer1.Stop;      MediaPlayer1.Stop;
72    ListView1.ClearItems;    ListView1.ClearItems;
73    Form3.Show;    Form3.Show;
74    if Assigned(th) = true then    if th <> nil then
75    begin    begin
76      th.Terminate;      th.Terminate;
77      th.WaitFor;      th.WaitFor;
78      th.Free;      FreeAndNil(th);
79    end;    end;
80    th := TSearchMP3.Create;    th := TSearchMP3.Create;
81  end;  end;
# Line 122  begin Line 124  begin
124      MediaPlayer1.Stop;      MediaPlayer1.Stop;
125      Action4.Text := 'Play';      Action4.Text := 'Play';
126    end    end
127    else    else if ListView1.ItemCount > 0 then
128    begin    begin
129      if (ListView1.ItemCount > 0) and (ListView1.ItemIndex = -1) then      if ListView1.ItemIndex = -1 then
130          PlayMusic(0)
131        else
132      begin      begin
133        ListView1.ItemIndex := 0;        MediaPlayer1.FileName := ListView1.Items[ListView1.ItemIndex].Detail;
       MediaPlayer1.FileName := ListView1.Items[0].Detail;  
134        TrackBar2.Max := MediaPlayer1.Duration;        TrackBar2.Max := MediaPlayer1.Duration;
135        TrackBar2.Value := 0;        MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value);
136          MediaPlayer1.Volume:=TrackBar1.Value;
137          MediaPlayer1.Play;
138      end;      end;
139      MediaPlayer1.Play;      MediaPlayer1.Play;
140      Action4.Text := 'Stop';      Action4.Text := 'Stop';
# Line 138  end; Line 143  end;
143    
144  procedure TForm1.Action5Execute(Sender: TObject);  procedure TForm1.Action5Execute(Sender: TObject);
145  begin  begin
146    MediaPlayer1.CurrentTime := MediaPlayer1.CurrentTime -    if MediaPlayer1.CurrentTime / (MediaTimeScale div 10000) < 5 then
147      MediaTimeScale div 1000;    begin
148    TrackBar2.Value := MediaPlayer1.CurrentTime;      if ListView1.ItemIndex > 0 then
149          PlayMusic(ListView1.ItemIndex - 1);
150      end
151      else
152      begin
153        MediaPlayer1.Stop;
154        MediaPlayer1.CurrentTime := 0;
155        TrackBar2.Value := 0;
156        Action4.Text := 'Play';
157      end;
158  end;  end;
159    
160  procedure TForm1.Action6Execute(Sender: TObject);  procedure TForm1.Action6Execute(Sender: TObject);
161    var
162      i: integer;
163  begin  begin
164    MediaPlayer1.CurrentTime := MediaPlayer1.CurrentTime +    if ListView1.ItemIndex < ListView1.ItemCount - 1 then
165      MediaTimeScale div 1000;    begin
166    TrackBar2.Value := MediaPlayer1.CurrentTime;      i := ListView1.ItemIndex + 1;
167        ListView1.ItemIndex := i;
168        PlayMusic(i);
169      end;
170  end;  end;
171    
172  procedure TForm1.FormDestroy(Sender: TObject);  procedure TForm1.FormDestroy(Sender: TObject);
173  begin  begin
174    Action2Execute(Sender);    Action2Execute(Sender);
175    if Assigned(th) = true then    if th <> nil then
176    begin    begin
177      th.Terminate;      th.Terminate;
178      th.WaitFor;      th.WaitFor;
# Line 185  begin Line 204  begin
204        Action1Execute(Sender);        Action1Execute(Sender);
205        Exit;        Exit;
206      end;      end;
207      Volume := TrackBar1.Value;      PlayMusic(ListView1.ItemIndex);
     TrackBar2.Max := Duration;  
     TrackBar2.Value := 0;  
     Play;  
208    end;    end;
209  end;  end;
210    
211    procedure TForm1.PlayMusic(Number: integer);
212    begin
213      ListView1.ItemIndex := Number;
214      MediaPlayer1.FileName := ListView1.Items[Number].Detail;
215      TrackBar2.Max := MediaPlayer1.Duration;
216      TrackBar2.Value := 0;
217      Action4.Text := 'Stop';
218      MediaPlayer1.Volume := TrackBar1.Value;
219      MediaPlayer1.Play;
220    end;
221    
222  procedure TForm1.SpeedButton1Click(Sender: TObject);  procedure TForm1.SpeedButton1Click(Sender: TObject);
223  begin  begin
224    Form2.Show;    Form2.Show;
# Line 210  begin Line 237  begin
237        begin        begin
238          Stop;          Stop;
239          Clear;          Clear;
240          FileName := ListView1.Items.Item[ListView1.ItemIndex].Detail;          FileName := ListView1.Items[ListView1.ItemIndex].Detail;
241          Volume := TrackBar1.Value;          Volume := TrackBar1.Value;
242          Play;          Play;
243        end;        end;
# Line 225  begin Line 252  begin
252    MediaPlayer1.Volume := TrackBar1.Value;    MediaPlayer1.Volume := TrackBar1.Value;
253  end;  end;
254    
255    procedure TForm1.TrackBar2Change(Sender: TObject);
256    begin
257      if Abs(TrackBar2.Value - MediaPlayer1.CurrentTime) > 200 then
258        MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value);
259    end;
260    
261  end.  end.

Legend:
Removed from v.2  
changed lines
  Added in v.6

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26