How can i get the length of the currently playing (or opened) file?
Couldn't find any thread about this.
File is beeing played with the StockAudioPlayer
uses WaveStorage;
function WaveLength(const FileName: String): DWORD;
var
Stream: TStream;
Adapter: TWaveStreamAdapter;
begin
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
Adapter := TWaveStreamAdapter.Create(Stream, soReference);
try
Result := Adapter.Length;
finally
Adapter.Free;
end;
finally
Stream.Free;
end;
end;
function WaveLength(const FileName: String): DWORD;
var
Stream: TStream;
Adapter: TWaveStreamAdapter;
filedir,todir:PAnsiChar;
toname:string;
begin
toname:=ExtractFilePath(Application.ExeName) + ExtractFileName('Templength.wav');
todir:=pansichar(toname);
filedir:=pansichar(filename);
copyfile(filedir,todir,false);
Stream := TFileStream.Create(toname, fmOpenRead);
try
Adapter := TWaveStreamAdapter.Create(Stream, soReference);
try
Result := Adapter.Length;
finally
Adapter.Free;
end;
finally
Stream.Free;
end;
deletefile(toname);
end;
procedure TForm.Volumebar1Change(Sender: TObject);
begin
Stockaudioplayer1.volume:=volumebar1.position;
end;
Return to DELPHI AREA Projects
Users browsing this forum: No registered users and 1 guest