Einzelnen Beitrag anzeigen

Anarchon

Registriert seit: 10. Jun 2006
6 Beiträge
 
Delphi 7 Enterprise
 
#1

BassDllPlayer Proplem mit trackbar

  Alt 15. Jun 2006, 05:31
hi,
Programmiere grad einen Mp3player mit einer Selbstlaufenenden trackbar!
(zum anzeigen der aktuellen Zeit des Songs)
problem ist sobald sich die Postion der Bar ändert stoppt der song!
(Also Song - Pause - Song - Pause - Song usw...
Hier der Code
Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,bass, Buttons, ExtCtrls, BassdllPlayer, ComCtrls, Menus
  ;

type
  TForm2 = class(TForm)
    SpeedButton1: TSpeedButton;
    pause: TSpeedButton;
    playbt: TSpeedButton;
    od: TOpenDialog;
    SpeedButton2: TSpeedButton;
    Image1: TImage;
    BassdllPlayer1: TBassdllPlayer;
    ListBox1: TListBox;
    Label1: TLabel;
    TrackBar1: TTrackBar;
    Timer1: TTimer;
    PopupMenu1: TPopupMenu;
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure playbtClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure pauseClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure poschange(Sender: TObject);
  private

  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}


procedure TForm2.FormCreate(Sender: TObject);
begin

   // check the correct BASS was loaded
   if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
   begin
      MessageBox(0,'An incorrect version of BASS.DLL was loaded',0,MB_ICONERROR);
      Halt;
   end;

   // Initialize audio - default device, 44100hz, stereo, 16 bits
   if not BASS_Init(-1, 44100, 0, Handle, nil) then
  begin

  End;
form2.Visible:=true;
end;

procedure TForm2.SpeedButton2Click(Sender: TObject);
begin
od.Execute;
listbox1.Items.Add(od.FileName);
end;


procedure TForm2.playbtClick(Sender: TObject);
begin
if (listbox1.ItemIndex > -1) then
bassdllplayer1.LoadFromFile(ListBox1.Items.Strings[Listbox1.ItemIndex]);
bassdllplayer1.Play;
label1.Caption:=bassdllplayer1.GetSongLengthAsString;
trackbar1.Max:=bassdllplayer1.SongLength;
end;

procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
bassdllplayer1.Stop;
timer1.Destroy;
bassdllplayer1.Destroy;
end;


procedure TForm2.pauseClick(Sender: TObject);
begin
bassdllplayer1.Pause;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
begin
//trackbar1.Position:=bassdllplayer1.Position;


end;

procedure TForm2.poschange(Sender: TObject);
begin
bassdllplayer1.Position:=trackbar1.Position;

end;
end.
  Mit Zitat antworten Zitat