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 1 by yamat0jp, Mon Jul 27 13:44:42 2015 UTC revision 4 by yamat0jp, Fri Jul 31 23:39:46 2015 UTC
# Line 25  type Line 25  type
25      Timer1: TTimer;      Timer1: TTimer;
26      ToolBar2: TToolBar;      ToolBar2: TToolBar;
27      TrackBar1: TTrackBar;      TrackBar1: TTrackBar;
     ToolBar3: TToolBar;  
28      TrackBar2: TTrackBar;      TrackBar2: TTrackBar;
29      SpeedButton4: TSpeedButton;      SpeedButton4: TSpeedButton;
30      SpeedButton5: TSpeedButton;      SpeedButton5: TSpeedButton;
# Line 33  type Line 32  type
32      Action4: TAction;      Action4: TAction;
33      Action5: TAction;      Action5: TAction;
34      Action6: TAction;      Action6: TAction;
35        StatusBar1: TStatusBar;
36      procedure Action1Execute(Sender: TObject);      procedure Action1Execute(Sender: TObject);
37      procedure ListView1ItemClick(const Sender: TObject;      procedure ListView1ItemClick(const Sender: TObject;
38        const AItem: TListViewItem);        const AItem: TListViewItem);
# 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.Play;
137      end;      end;
138      MediaPlayer1.Play;      MediaPlayer1.Play;
139      Action4.Text := 'Stop';      Action4.Text := 'Stop';
# Line 138  end; Line 142  end;
142    
143  procedure TForm1.Action5Execute(Sender: TObject);  procedure TForm1.Action5Execute(Sender: TObject);
144  begin  begin
145    MediaPlayer1.CurrentTime := MediaPlayer1.CurrentTime -    if MediaPlayer1.CurrentTime < MediaTimeScale div 10000 then
146      MediaTimeScale div 1000;      if ListView1.ItemCount > 0 then
147    TrackBar2.Value := MediaPlayer1.CurrentTime;        PlayMusic(ListView1.ItemIndex - 1)
148        else
149        begin
150          MediaPlayer1.Stop;
151          MediaPlayer1.CurrentTime := 0;
152          TrackBar2.Value := 0;
153          Action4.Text := 'Play';
154        end;
155  end;  end;
156    
157  procedure TForm1.Action6Execute(Sender: TObject);  procedure TForm1.Action6Execute(Sender: TObject);
158    var
159      i: integer;
160  begin  begin
161    MediaPlayer1.CurrentTime := MediaPlayer1.CurrentTime +    if ListView1.ItemIndex < ListView1.ItemCount - 1 then
162      MediaTimeScale div 1000;    begin
163    TrackBar2.Value := MediaPlayer1.CurrentTime;      i := ListView1.ItemIndex + 1;
164        ListView1.ItemIndex := i;
165        PlayMusic(i);
166      end;
167  end;  end;
168    
169  procedure TForm1.FormDestroy(Sender: TObject);  procedure TForm1.FormDestroy(Sender: TObject);
170  begin  begin
171    Action2Execute(Sender);    Action2Execute(Sender);
172    if Assigned(th) = true then    if th <> nil then
173    begin    begin
174      th.Terminate;      th.Terminate;
175      th.WaitFor;      th.WaitFor;
# Line 185  begin Line 201  begin
201        Action1Execute(Sender);        Action1Execute(Sender);
202        Exit;        Exit;
203      end;      end;
204      Volume := TrackBar1.Value;      PlayMusic(ListView1.ItemIndex);
     TrackBar2.Max := Duration;  
     TrackBar2.Value := 0;  
     Play;  
205    end;    end;
206  end;  end;
207    
208    procedure TForm1.PlayMusic(Number: integer);
209    begin
210      ListView1.ItemIndex := Number;
211      MediaPlayer1.FileName := ListView1.Items[Number].Detail;
212      TrackBar2.Max := MediaPlayer1.Duration;
213      TrackBar2.Value := 0;
214      Action4.Text := 'Stop';
215      MediaPlayer1.Play;
216    end;
217    
218  procedure TForm1.SpeedButton1Click(Sender: TObject);  procedure TForm1.SpeedButton1Click(Sender: TObject);
219  begin  begin
220    Form2.Show;    Form2.Show;
# Line 210  begin Line 233  begin
233        begin        begin
234          Stop;          Stop;
235          Clear;          Clear;
236          FileName := ListView1.Items.Item[ListView1.ItemIndex].Detail;          FileName := ListView1.Items[ListView1.ItemIndex].Detail;
237          Volume := TrackBar1.Value;          Volume := TrackBar1.Value;
238          Play;          Play;
239        end;        end;
# Line 225  begin Line 248  begin
248    MediaPlayer1.Volume := TrackBar1.Value;    MediaPlayer1.Volume := TrackBar1.Value;
249  end;  end;
250    
251    procedure TForm1.TrackBar2Change(Sender: TObject);
252    begin
253      if (TrackBar2.Value < MediaPlayer1.CurrentTime) or
254        (TrackBar2.Value > MediaPlayer1.CurrentTime + MediaTimeScale div 800) then
255        MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value);
256    end;
257    
258  end.  end.

Legend:
Removed from v.1  
changed lines
  Added in v.4

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