unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mp3Data, SQLite3Commons, SQLite3;
type
TMainform =
class(TForm)
Ed_DBPath: TEdit;
Btn_Open: TButton;
Btn_List: TButton;
Odlg_DB: TOpenDialog;
Lb_Result: TListBox;
procedure Btn_ListClick(Sender: TObject);
procedure Btn_OpenClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Mainform: TMainform;
MediaPath:
String;
implementation
{$R *.dfm}
procedure TMainform.Btn_OpenClick(Sender: TObject);
begin
if Odlg_DB.Execute
then
begin
if Odlg_DB.FileName <> '
'
then
begin
MediaPath := Odlg_DB.FileName;
Ed_DBPath.Text := MediaPath;
end;
end;
end;
procedure TMainform.Btn_ListClick(Sender: TObject);
var
Client: TSQLRestClient;
Table: TSQLTable;
Mp3Model: TSQLModel;
// 'Model' for database
Mp3Record: TSQLMp3Record;
// Record for database
begin
if MediaPath <> '
'
then
begin
Mp3Model := TSQLModel.Create([TSQLMp3Record], '
root');
Mp3Record := TSQLMp3Record.Create;
Client := TSQLRestClientDB.Create(Mp3Model, MediaPath);
Table := Client.List([TSQLMp3Record], '
*', '
Genre = "Asian Music"');
if Table <>
nil then // = nil on any error
try
Mp3Record.FillPrepare(Table);
while Mp3Record.FillOne
do
begin
Lb_Result.Items.Add(Mp3Record.Title);
end;
finally
Table.Free;
end;
Mp3Model.Free;
Mp3Record.Free;
end;
end;
end.