Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Unit1.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Mon Jul 27 13:44:42 2015 UTC (8 years, 7 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 5580 byte(s)
最初のコミット
1 unit Unit1;
2
3 interface
4
5 uses
6 System.SysUtils, System.Types, System.UITypes, System.Classes,
7 System.Variants, System.IOUtils, System.Math,
8 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Media,
9 System.Actions, FMX.ActnList, FMX.Layouts, FMX.ListBox, FMX.StdCtrls,
10 FMX.ListView.Types, FMX.ListView;
11
12 type
13 TForm1 = class(TForm)
14 MediaPlayer1: TMediaPlayer;
15 ActionList1: TActionList;
16 Action1: TAction;
17 ListView1: TListView;
18 Action2: TAction;
19 Action3: TAction;
20 Panel1: TPanel;
21 SpeedButton1: TSpeedButton;
22 SpeedButton2: TSpeedButton;
23 ToolBar1: TToolBar;
24 SpeedButton3: TSpeedButton;
25 Timer1: TTimer;
26 ToolBar2: TToolBar;
27 TrackBar1: TTrackBar;
28 ToolBar3: TToolBar;
29 TrackBar2: TTrackBar;
30 SpeedButton4: TSpeedButton;
31 SpeedButton5: TSpeedButton;
32 SpeedButton6: TSpeedButton;
33 Action4: TAction;
34 Action5: TAction;
35 Action6: TAction;
36 procedure Action1Execute(Sender: TObject);
37 procedure ListView1ItemClick(const Sender: TObject;
38 const AItem: TListViewItem);
39 procedure Action2Execute(Sender: TObject);
40 procedure Action3Execute(Sender: TObject);
41 procedure SpeedButton1Click(Sender: TObject);
42 procedure FormShow(Sender: TObject);
43 procedure FormDestroy(Sender: TObject);
44 procedure Timer1Timer(Sender: TObject);
45 procedure TrackBar1Change(Sender: TObject);
46 procedure Action4Execute(Sender: TObject);
47 procedure Action6Execute(Sender: TObject);
48 procedure Action5Execute(Sender: TObject);
49 private
50 { private ���� }
51 public
52 { public ���� }
53 th: TThread;
54 end;
55
56 var
57 Form1: TForm1;
58
59 implementation
60
61 {$R *.fmx}
62 {$R *.LgXhdpiTb.fmx ANDROID}
63
64 uses Unit2, Unit3, Unit4;
65
66 procedure TForm1.Action1Execute(Sender: TObject);
67 begin
68 if MediaPlayer1.State = TMediaState.Playing then
69 MediaPlayer1.Stop;
70 ListView1.ClearItems;
71 Form3.Show;
72 if Assigned(th) = true then
73 begin
74 th.Terminate;
75 th.WaitFor;
76 th.Free;
77 end;
78 th := TSearchMP3.Create;
79 end;
80
81 procedure TForm1.Action2Execute(Sender: TObject);
82 var
83 s: TStringList;
84 t: TListViewItem;
85 begin
86 s := TStringList.Create;
87 try
88 for t in ListView1.Items do
89 s.Add(t.Detail);
90 s.SaveToFile(TPath.GetHomePath + TPath.DirectorySeparatorChar + 'Path.txt');
91 finally
92 s.Free;
93 end;
94 end;
95
96 procedure TForm1.Action3Execute(Sender: TObject);
97 var
98 s: TStringList;
99 t: string;
100 begin
101 ListView1.ClearItems;
102 s := TStringList.Create;
103 try
104 s.LoadFromFile(TPath.GetHomePath + TPath.DirectorySeparatorChar +
105 'Path.txt');
106 for t in s do
107 if FileExists(t) = true then
108 with ListView1.Items.Add do
109 begin
110 Detail := t;
111 Text := ExtractFileName(t);
112 end;
113 finally
114 s.Free;
115 end;
116 end;
117
118 procedure TForm1.Action4Execute(Sender: TObject);
119 begin
120 if MediaPlayer1.State = TMediaState.Playing then
121 begin
122 MediaPlayer1.Stop;
123 Action4.Text := 'Play';
124 end
125 else
126 begin
127 if (ListView1.ItemCount > 0) and (ListView1.ItemIndex = -1) then
128 begin
129 ListView1.ItemIndex := 0;
130 MediaPlayer1.FileName := ListView1.Items[0].Detail;
131 TrackBar2.Max := MediaPlayer1.Duration;
132 TrackBar2.Value := 0;
133 end;
134 MediaPlayer1.Play;
135 Action4.Text := 'Stop';
136 end;
137 end;
138
139 procedure TForm1.Action5Execute(Sender: TObject);
140 begin
141 MediaPlayer1.CurrentTime := MediaPlayer1.CurrentTime -
142 MediaTimeScale div 1000;
143 TrackBar2.Value := MediaPlayer1.CurrentTime;
144 end;
145
146 procedure TForm1.Action6Execute(Sender: TObject);
147 begin
148 MediaPlayer1.CurrentTime := MediaPlayer1.CurrentTime +
149 MediaTimeScale div 1000;
150 TrackBar2.Value := MediaPlayer1.CurrentTime;
151 end;
152
153 procedure TForm1.FormDestroy(Sender: TObject);
154 begin
155 Action2Execute(Sender);
156 if Assigned(th) = true then
157 begin
158 th.Terminate;
159 th.WaitFor;
160 th.Free;
161 end;
162 end;
163
164 procedure TForm1.FormShow(Sender: TObject);
165 begin
166 if FileExists(TPath.GetHomePath + TPath.DirectorySeparatorChar + 'Path.txt') = true
167 then
168 Action3Execute(Sender)
169 else
170 Action1Execute(Sender);
171 end;
172
173 procedure TForm1.ListView1ItemClick(const Sender: TObject;
174 const AItem: TListViewItem);
175 begin
176 with MediaPlayer1 do
177 begin
178 if State = TMediaState.Playing then
179 Stop;
180 Clear;
181 if FileExists(AItem.Detail) = true then
182 FileName := AItem.Detail
183 else
184 begin
185 Action1Execute(Sender);
186 Exit;
187 end;
188 Volume := TrackBar1.Value;
189 TrackBar2.Max := Duration;
190 TrackBar2.Value := 0;
191 Play;
192 end;
193 end;
194
195 procedure TForm1.SpeedButton1Click(Sender: TObject);
196 begin
197 Form2.Show;
198 end;
199
200 procedure TForm1.Timer1Timer(Sender: TObject);
201 begin
202 if (ListView1.ItemIndex > -1) and
203 (Trunc(10000 * MediaPlayer1.Duration / MediaTimeScale) <=
204 Ceil(10000 * MediaPlayer1.CurrentTime / MediaTimeScale)) then
205 begin
206 if ListView1.ItemIndex < ListView1.Items.Count - 1 then
207 begin
208 ListView1.ItemIndex := ListView1.ItemIndex + 1;
209 with MediaPlayer1 do
210 begin
211 Stop;
212 Clear;
213 FileName := ListView1.Items.Item[ListView1.ItemIndex].Detail;
214 Volume := TrackBar1.Value;
215 Play;
216 end;
217 end;
218 end;
219 if MediaPlayer1.State = TMediaState.Playing then
220 TrackBar2.Value := MediaPlayer1.CurrentTime;
221 end;
222
223 procedure TForm1.TrackBar1Change(Sender: TObject);
224 begin
225 MediaPlayer1.Volume := TrackBar1.Value;
226 end;
227
228 end.

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