private
{ Private declarations }
procedure StopRec;
procedure TForm1.StopRec;
var
Root, CCRDir, ChannelDir, FileName :
String;
begin
Root:=GetSpecialFolderForMP3(
Handle, CSIDL_PERSONAL);
CCRDir:='
CCRadio Recordings';
ChannelDir:=Label4.Caption;
//FileName:='my.mp3';
FileName:=FormatDateTime('
dd.mm.yy', date) + '
- ' + FormatDateTime('
hh.nn.ss', time) + '
.mp3';
ChannelDir:=StringReplace(ChannelDir, '
\', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
/', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
:', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
*', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
?', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
"', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
<', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
>', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
|', '
', [rfReplaceAll]);
ChannelDir:=StringReplace(ChannelDir, '
.', '
', [rfReplaceAll]);
if DirectoryExists(Root + '
\' + CCRDir)
then
begin
if DirectoryExists(Root + '
\' + CCRDir + '
\' + ChannelDir)
then
begin
//showmessage(Root + '\' + CCRDir + '\' + ChannelDir);
Filestream:=TFileStream.Create(Root + '
\' + CCRDir + '
\' + ChannelDir + '
\' + FileName, fmCreate);
end else if (
not CreateDir(Root + '
\' + CCRDir + '
\' + ChannelDir))
then
begin
SaveDialog1.FileName:=FileName;
if SaveDialog1.Execute
then //WaveStream.SaveToFile(SaveDialog1.FileName);
end else
begin
CreateDir(Root + '
\' + CCRDir + '
\' + ChannelDir);
Filestream:=TFileStream.Create(Root + '
\' + CCRDir + '
\' + ChannelDir + '
\' + FileName, fmCreate);
end;
end else if (
not CreateDir(Root + '
\' + CCRDir))
then
begin
SaveDialog1.FileName:=FileName;
if SaveDialog1.Execute
then //WaveStream.SaveToFile(SaveDialog1.FileName);
end else
begin
CreateDir(Root + '
\' + CCRDir);
if DirectoryExists(Root + '
\' + CCRDir + '
\' + ChannelDir)
then
begin
Filestream:=TFileStream.Create(Root + '
\' + CCRDir + '
\' + ChannelDir + '
\' + FileName, fmCreate);
end else if (
not CreateDir(Root + '
\' + CCRDir + '
\' + ChannelDir))
then
begin
SaveDialog1.FileName:=FileName;
if SaveDialog1.Execute
then //WaveStream.SaveToFile(SaveDialog1.FileName);
end else
begin
CreateDir(Root + '
\' + CCRDir + '
\' + ChannelDir);
Filestream:=TFileStream.Create(Root + '
\' + CCRDir + '
\' + ChannelDir + '
\' + FileName, fmCreate);
end;
end;
//RecordStatus:=False;
end;
procedure StatusProc(buffer: Pointer; len, user: DWORD);
stdcall;
begin
if (buffer <>
nil)
and (len = 0)
then
SendMessage(win, WM_INFO_UPDATE, 8, DWORD(PChar(buffer)));
if (FileStream =
nil)
then
Form1.StopRec;
if (buffer =
nil)
then
FileStream.Free
// finished downloading
else
FileStream.
Write(buffer^, len);
end;