| 15 |
ActionList1: TActionList; |
ActionList1: TActionList; |
| 16 |
Action1: TAction; |
Action1: TAction; |
| 17 |
ListView1: TListView; |
ListView1: TListView; |
|
Action2: TAction; |
|
| 18 |
Action3: TAction; |
Action3: TAction; |
|
Panel1: TPanel; |
|
| 19 |
SpeedButton1: TSpeedButton; |
SpeedButton1: TSpeedButton; |
| 20 |
SpeedButton2: TSpeedButton; |
SpeedButton2: TSpeedButton; |
|
ToolBar1: TToolBar; |
|
| 21 |
SpeedButton3: TSpeedButton; |
SpeedButton3: TSpeedButton; |
| 22 |
Timer1: TTimer; |
Timer1: TTimer; |
|
ToolBar2: TToolBar; |
|
| 23 |
TrackBar1: TTrackBar; |
TrackBar1: TTrackBar; |
| 24 |
TrackBar2: TTrackBar; |
TrackBar2: TTrackBar; |
| 25 |
SpeedButton4: TSpeedButton; |
SpeedButton4: TSpeedButton; |
| 29 |
Action5: TAction; |
Action5: TAction; |
| 30 |
Action6: TAction; |
Action6: TAction; |
| 31 |
StatusBar1: TStatusBar; |
StatusBar1: TStatusBar; |
| 32 |
|
ToolBar1: TToolBar; |
| 33 |
|
ToolBar2: TToolBar; |
| 34 |
procedure Action1Execute(Sender: TObject); |
procedure Action1Execute(Sender: TObject); |
| 35 |
procedure ListView1ItemClick(const Sender: TObject; |
procedure ListView1ItemClick(const Sender: TObject; |
| 36 |
const AItem: TListViewItem); |
const AItem: TListViewItem); |
|
procedure Action2Execute(Sender: TObject); |
|
| 37 |
procedure Action3Execute(Sender: TObject); |
procedure Action3Execute(Sender: TObject); |
| 38 |
procedure SpeedButton1Click(Sender: TObject); |
procedure SpeedButton1Click(Sender: TObject); |
| 39 |
procedure FormShow(Sender: TObject); |
procedure FormShow(Sender: TObject); |
| 44 |
procedure Action6Execute(Sender: TObject); |
procedure Action6Execute(Sender: TObject); |
| 45 |
procedure Action5Execute(Sender: TObject); |
procedure Action5Execute(Sender: TObject); |
| 46 |
procedure TrackBar2Change(Sender: TObject); |
procedure TrackBar2Change(Sender: TObject); |
| 47 |
|
procedure FormCreate(Sender: TObject); |
| 48 |
private |
private |
| 49 |
{ private 宣言 } |
{ private 宣言 } |
| 50 |
public |
public |
| 51 |
{ public 宣言 } |
{ public 宣言 } |
| 52 |
th: TThread; |
th: TThread; |
| 53 |
|
list: TStringList; |
| 54 |
procedure PlayMusic(Number: integer); |
procedure PlayMusic(Number: integer); |
| 55 |
|
procedure Id3Tag; |
| 56 |
end; |
end; |
| 57 |
|
|
| 58 |
var |
var |
| 63 |
{$R *.fmx} |
{$R *.fmx} |
| 64 |
{$R *.LgXhdpiTb.fmx ANDROID} |
{$R *.LgXhdpiTb.fmx ANDROID} |
| 65 |
|
|
| 66 |
uses Unit2, Unit3, Unit4; |
uses Unit2, Unit3, Unit4, Mp3FileUtils; |
| 67 |
|
|
| 68 |
procedure TForm1.Action1Execute(Sender: TObject); |
procedure TForm1.Action1Execute(Sender: TObject); |
| 69 |
begin |
begin |
| 80 |
th := TSearchMP3.Create; |
th := TSearchMP3.Create; |
| 81 |
end; |
end; |
| 82 |
|
|
|
procedure TForm1.Action2Execute(Sender: TObject); |
|
|
var |
|
|
s: TStringList; |
|
|
t: TListViewItem; |
|
|
begin |
|
|
s := TStringList.Create; |
|
|
try |
|
|
for t in ListView1.Items do |
|
|
s.Add(t.Detail); |
|
|
s.SaveToFile(TPath.GetHomePath + TPath.DirectorySeparatorChar + 'Path.txt'); |
|
|
finally |
|
|
s.Free; |
|
|
end; |
|
|
end; |
|
|
|
|
| 83 |
procedure TForm1.Action3Execute(Sender: TObject); |
procedure TForm1.Action3Execute(Sender: TObject); |
| 84 |
var |
var |
| 85 |
s: TStringList; |
s: TStringList; |
| 86 |
t: string; |
t: string; |
| 87 |
begin |
begin |
| 88 |
ListView1.ClearItems; |
ListView1.ClearItems; |
| 89 |
s := TStringList.Create; |
list.LoadFromFile(TPath.GetHomePath + TPath.DirectorySeparatorChar + |
| 90 |
try |
'Path.txt'); |
| 91 |
s.LoadFromFile(TPath.GetHomePath + TPath.DirectorySeparatorChar + |
Id3Tag; |
|
'Path.txt'); |
|
|
for t in s do |
|
|
if FileExists(t) = true then |
|
|
with ListView1.Items.Add do |
|
|
begin |
|
|
Detail := t; |
|
|
Text := ExtractFileName(t); |
|
|
end; |
|
|
finally |
|
|
s.Free; |
|
|
end; |
|
| 92 |
end; |
end; |
| 93 |
|
|
| 94 |
procedure TForm1.Action4Execute(Sender: TObject); |
procedure TForm1.Action4Execute(Sender: TObject); |
| 107 |
MediaPlayer1.FileName := ListView1.Items[ListView1.ItemIndex].Detail; |
MediaPlayer1.FileName := ListView1.Items[ListView1.ItemIndex].Detail; |
| 108 |
TrackBar2.Max := MediaPlayer1.Duration; |
TrackBar2.Max := MediaPlayer1.Duration; |
| 109 |
MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value); |
MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value); |
| 110 |
MediaPlayer1.Volume:=TrackBar1.Value; |
MediaPlayer1.Volume := TrackBar1.Value; |
| 111 |
MediaPlayer1.Play; |
MediaPlayer1.Play; |
| 112 |
end; |
end; |
| 113 |
MediaPlayer1.Play; |
MediaPlayer1.Play; |
| 127 |
MediaPlayer1.Stop; |
MediaPlayer1.Stop; |
| 128 |
MediaPlayer1.CurrentTime := 0; |
MediaPlayer1.CurrentTime := 0; |
| 129 |
TrackBar2.Value := 0; |
TrackBar2.Value := 0; |
| 130 |
Action4.Text := 'Play'; |
Action4.Text := 'Stop'; |
| 131 |
|
MediaPlayer1.Play; |
| 132 |
end; |
end; |
| 133 |
end; |
end; |
| 134 |
|
|
| 144 |
end; |
end; |
| 145 |
end; |
end; |
| 146 |
|
|
| 147 |
|
procedure TForm1.FormCreate(Sender: TObject); |
| 148 |
|
begin |
| 149 |
|
list := TStringList.Create; |
| 150 |
|
end; |
| 151 |
|
|
| 152 |
procedure TForm1.FormDestroy(Sender: TObject); |
procedure TForm1.FormDestroy(Sender: TObject); |
| 153 |
|
var |
| 154 |
|
i: integer; |
| 155 |
begin |
begin |
| 156 |
Action2Execute(Sender); |
list.SaveToFile(TPath.GetHomePath + TPath.DirectorySeparatorChar + |
| 157 |
|
'Path.txt'); |
| 158 |
|
list.Free; |
| 159 |
if th <> nil then |
if th <> nil then |
| 160 |
begin |
begin |
| 161 |
th.Terminate; |
th.Terminate; |
| 173 |
Action1Execute(Sender); |
Action1Execute(Sender); |
| 174 |
end; |
end; |
| 175 |
|
|
| 176 |
|
procedure TForm1.Id3Tag; |
| 177 |
|
var |
| 178 |
|
s: string; |
| 179 |
|
Id3v2Tag: TId3v2Tag; |
| 180 |
|
m: TMemoryStream; |
| 181 |
|
begin |
| 182 |
|
for s in list do |
| 183 |
|
begin |
| 184 |
|
Id3v2Tag := TId3v2Tag.Create; |
| 185 |
|
m := TMemoryStream.Create; |
| 186 |
|
try |
| 187 |
|
Id3v2Tag.ReadFromFile(s); |
| 188 |
|
Id3v2Tag.GetPicture(m, '*'); |
| 189 |
|
with ListView1.Items.Add do |
| 190 |
|
begin |
| 191 |
|
Bitmap.LoadFromStream(m); |
| 192 |
|
Text := Id3v2Tag.Title; |
| 193 |
|
Detail := s; |
| 194 |
|
end; |
| 195 |
|
finally |
| 196 |
|
Id3v2Tag.Free; |
| 197 |
|
m.Free; |
| 198 |
|
end; |
| 199 |
|
end; |
| 200 |
|
Form3.Hide; |
| 201 |
|
list.SaveToFile(TPath.GetHomePath + TPath.DirectorySeparatorChar + |
| 202 |
|
'Path.txt'); |
| 203 |
|
end; |
| 204 |
|
|
| 205 |
procedure TForm1.ListView1ItemClick(const Sender: TObject; |
procedure TForm1.ListView1ItemClick(const Sender: TObject; |
| 206 |
const AItem: TListViewItem); |
const AItem: TListViewItem); |
| 207 |
begin |
begin |
| 208 |
with MediaPlayer1 do |
if FileExists(ListView1.Items[ListView1.ItemIndex].Detail) = true then |
| 209 |
begin |
PlayMusic(ListView1.ItemIndex) |
| 210 |
if State = TMediaState.Playing then |
else |
| 211 |
Stop; |
Action1Execute(Sender); |
|
Clear; |
|
|
if FileExists(AItem.Detail) = true then |
|
|
FileName := AItem.Detail |
|
|
else |
|
|
begin |
|
|
Action1Execute(Sender); |
|
|
Exit; |
|
|
end; |
|
|
PlayMusic(ListView1.ItemIndex); |
|
|
end; |
|
| 212 |
end; |
end; |
| 213 |
|
|
| 214 |
procedure TForm1.PlayMusic(Number: integer); |
procedure TForm1.PlayMusic(Number: integer); |
| 215 |
begin |
begin |
| 216 |
ListView1.ItemIndex := Number; |
ListView1.ItemIndex := Number; |
| 217 |
|
MediaPlayer1.Stop; |
| 218 |
|
MediaPlayer1.Clear; |
| 219 |
MediaPlayer1.FileName := ListView1.Items[Number].Detail; |
MediaPlayer1.FileName := ListView1.Items[Number].Detail; |
| 220 |
TrackBar2.Max := MediaPlayer1.Duration; |
TrackBar2.Max := MediaPlayer1.Duration; |
| 221 |
TrackBar2.Value := 0; |
TrackBar2.Value := 0; |
| 232 |
procedure TForm1.Timer1Timer(Sender: TObject); |
procedure TForm1.Timer1Timer(Sender: TObject); |
| 233 |
begin |
begin |
| 234 |
if (ListView1.ItemIndex > -1) and |
if (ListView1.ItemIndex > -1) and |
| 235 |
(Trunc(10000 * MediaPlayer1.Duration / MediaTimeScale) <= |
((MediaPlayer1.Duration - MediaPlayer1.CurrentTime) / |
| 236 |
Ceil(10000 * MediaPlayer1.CurrentTime / MediaTimeScale)) then |
(MediaTimeScale div 10000) < 1) then |
| 237 |
begin |
begin |
| 238 |
if ListView1.ItemIndex < ListView1.Items.Count - 1 then |
if ListView1.ItemIndex < ListView1.Items.Count - 1 then |
| 239 |
begin |
PlayMusic(ListView1.ItemIndex + 1); |
| 240 |
ListView1.ItemIndex := ListView1.ItemIndex + 1; |
end |
| 241 |
with MediaPlayer1 do |
else if MediaPlayer1.State = TMediaState.Playing then |
|
begin |
|
|
Stop; |
|
|
Clear; |
|
|
FileName := ListView1.Items[ListView1.ItemIndex].Detail; |
|
|
Volume := TrackBar1.Value; |
|
|
Play; |
|
|
end; |
|
|
end; |
|
|
end; |
|
|
if MediaPlayer1.State = TMediaState.Playing then |
|
| 242 |
TrackBar2.Value := MediaPlayer1.CurrentTime; |
TrackBar2.Value := MediaPlayer1.CurrentTime; |
| 243 |
end; |
end; |
| 244 |
|
|
| 249 |
|
|
| 250 |
procedure TForm1.TrackBar2Change(Sender: TObject); |
procedure TForm1.TrackBar2Change(Sender: TObject); |
| 251 |
begin |
begin |
| 252 |
if Abs(TrackBar2.Value - MediaPlayer1.CurrentTime) > 200 then |
if Abs(TrackBar2.Value - MediaPlayer1.CurrentTime) > MediaTimeScale div 5000 |
| 253 |
|
then |
| 254 |
MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value); |
MediaPlayer1.CurrentTime := Trunc(TrackBar2.Value); |
| 255 |
end; |
end; |
| 256 |
|
|