Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi bass.dll Trackbar Problem (https://www.delphipraxis.net/87699-bass-dll-trackbar-problem.html)

iron 4. Mär 2007 22:46


bass.dll Trackbar Problem
 
es sieht folgendermaßen aus, wenn ich über OpenDialog ein mp3song suche und abspiele

Delphi-Quellcode:
procedure TForm11.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then begin
   BASS_Init(-1, 44100, 0, Application.Handle, nil);
   OpenDialog1.Title := 'MP3 suchen';
   OpenDialog1.Filter := 'mp3|*.mp3';
   Channel := BASS_StreamCreateFile(FALSE, PChar(OpenDialog1.FileName), 0, 0, 0);
   BASS_ChannelPlay(Channel, False);
   TrackBar1.Max:=GetSetSoundInfo('GetLength');
dann bewegt sich die Trackbar zum Lied mit und ich kann die Position ändern, alles Prima.

aber wenn ich es über eine ListBox anklicke, das sich die Musik aus der Datenbank holt geht es nicht.

Delphi-Quellcode:
procedure TForm11.ListBox1Click(Sender: TObject);
var
x,i,w : integer;
BASS_Init(-1, 44100, 0, Application.Handle, nil);
  w := ListBox1.ItemIndex;
  i := BASS_StreamCreateFile(False, PChar(Form2.mp3ABSTable.fields[2].Asstring + '\' +
                                          Form2.mp3ABSTable.fields[0].Asstring + '\' +
                                          Form2.mp3ABSTable.fields[1].Asstring + '\' +
                                          ListBox1.Items.Strings[w]), 0, 0, 0);
    BASS_ChannelPlay(i , False);
    TrackBar1.Max:=GetSetSoundInfo('GetLength');
Das abspielen funktioniert, nur die Trackbar bewegt sich in diesem Fall nicht.

hier mal den Code für die Anweisungen

Delphi-Quellcode:
function TForm11.GetSetSoundInfo(Info: String): Int64;
var
MilliSec: Integer;
FloatPos: Float;
begin
 If Info = 'GetLength' then FloatPos:=BASS_ChannelBytes2Seconds(Channel, BASS_ChannelGetLength(Channel))
 Else If Info = 'GetPosition' then FloatPos:=BASS_ChannelBytes2Seconds(Channel, BASS_ChannelGetPosition(Channel));
 MilliSec:=Trunc(1000 * FloatPos);
 If MilliSec < 0 then MilliSec:=0;
 Result:=MilliSec;
end;
Delphi-Quellcode:
procedure TForm11.Timer1Timer(Sender: TObject);
begin
 TrackBar1.Position:=GetSetSoundInfo('GetPosition');
end;
Delphi-Quellcode:
procedure TForm11.TrackBar1Change(Sender: TObject);
var
TBP, BGP: Integer;
begin
 TBP:=TrackBar1.Position;
 BGP:=GetSetSoundInfo('GetPosition');
 If ABS(TBP - BGP) > 1000 then
 BASS_ChannelSetPosition(Channel, BASS_ChannelSeconds2Bytes(Channel, TrackBar1.Position div 1000));
end;
hat wer einer eine Idee was ich falsch mache???

turboPASCAL 4. Mär 2007 23:17

Re: bass.dll Trackbar Problem
 
Oweh autsch... :wink:


Eh ich alles Lang und Breit eErkläre schau Dir bitte mal das Demo an.

Falls du dann noch Probleme hast gucken wir mal. :stupid:

Clobber the mob 8. Mai 2007 12:05

Re: bass.dll Trackbar Problem
 
Delphi-Quellcode:
procedure TForm1.TrackBarScroll(Sender: TObject; ScrollCode: TScrollCode;
  var ScrollPos: Integer);
begin
  if ScrollCode = scEndScroll then begin
    BASS_ChannelSetPosition(stream, Trackbar.Position);
    Tracking := False;
  end else
    Tracking := True;
end;
ich habs mit nem Timer gemacht:

Delphi-Quellcode:
procedure TForm1.TrackBarTimerTimer(Sender: TObject);
begin
  if Tracking = False then
  TrackBar.Position := BASS_ChannelGetPosition(stream);
end;
Hoffe das hilft dir weiter


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:53 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz