Einzelnen Beitrag anzeigen

Wishmaster

Registriert seit: 14. Sep 2002
Ort: Steinbach, MB, Canada
301 Beiträge
 
Delphi XE2 Architect
 
#4

Re: Bass.dll und Anwendung schließt nicht

  Alt 30. Jun 2009, 11:28
Hi

dein code ist ein-wenig verwirrend!
1, BASS_StreamCreateFile hat keinen Flag BASS_MUSIC_RAMP nur BASS_MusicLoad hat
2, in TPlayer.Pause; benutzt du BASS_ChannelStop Warum ???
3, was soll das ganze FPause, FPlay, Fstop???

Delphi-Quellcode:
unit UBassPlayer;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, bass;

type
  TPlayStatus = (plOpen, plActive, plPaused, plStopt, plStalled, plEnd);

  TPlayer = class
  private
    fStatus : TPlayStatus;
    strs: HSTREAM;
  public
    constructor CreatePlayer();
    Procedure FreePlayer;

    Function LoadFile(Filename : String) : Boolean;
    Function Play() : Boolean;
    Function Pause() : Boolean;
    Function Resume() : Boolean;
    Function Stop() : Boolean;
    Property Get_PlaybackStatus : TPlayStatus read fStatus;
  end;

implementation


Function TPlayer.LoadFile(Filename : String) : Boolean;
begin
  BASS_StreamFree(strs);
  strs:= BASS_StreamCreateFile(False, PChar(Filename), 0, 0, BASS_STREAM_AUTOFREE);
 if strs = 0 then
  begin
    Result:= false;
   Exit;
  end;
  fStatus:= plOpen;
  Result:= true;
end;

Function TPlayer.Play() : Boolean;
begin
  Result:= BASS_ChannelPlay(strs, true);
 if Result then
  begin
   fStatus:= plActive;
  end;
end;

Function TPlayer.Pause() : Boolean;
begin
  Result:= BASS_ChannelPause(STRS);
 if Result then
  begin
   fStatus:= plPause;
  end;
end;


Function TPlayer.Resume() : Boolean;
begin
  Result:= BASS_ChannelPlay(STRS, false);
 if Result then
  begin
   fStatus:= plActive;
  end;
end;

Function TPlayer.Stop() : Boolean;
begin
  Result:= BASS_ChannelStop(STRS);
 if Result then
  begin
   fStatus:= plStopt;
  end;
end;

constructor TPlayer.CreatePlayer() : Boolean;
begin
  inherited Create;
     if (HIWORD(BASS_GetVersion) <> BASSVERSION) then
   begin
      MessageBox(0,'An incorrect version of BASS.DLL was loaded',nil, MB_ICONERROR);
      Halt;
   end;

   // Initialize audio - default device, 44100hz, stereo, 16 bits
   if not BASS_Init(-1, 44100, 0, Application.Handle, nil) then
      showmessage('Error initializing audio!');
end;


end.
  Mit Zitat antworten Zitat