unit DFormatXM;

interface

uses
  dtypes,
  dstream,
  DEngBase,
  DMusic_openal;

{type
TXMPlayer = object(TMusicPlayer)
private
  FVolume: Integer;
public
  constructor Create;
  function OnLoad(Stream: PStream): Boolean; override; overload;
  function OnLoad(const FileName: TString): Boolean; override; overload;
  procedure OnPlay; override;
  procedure OnStop; override;
  procedure OnPause; override;
  procedure SetVolume(Volume: Integer); override;
  function GetVolume: Integer; override;
end;

TXMLoader = object(TMusicLoader)
  function Load(Stream: PStream): TMusicPlayer; override; overload;
  function Load(const FileName: TString): TMusicPlayer; override; overload;
end;}

implementation

uses
  uFMOD;

//{$IFNDEF FLAG_FPC}{$REGION 'TXMPlayer'}{$ENDIF}
//constructor TXMPlayer.Create;
//begin
//  FVolume := DENG_MAX_VOLUME * (uFMOD_DEFAULT_VOL - uFMOD_MIN_VOL) div (uFMOD_MAX_VOL - uFMOD_MIN_VOL);
//end;

//function TXMPlayer.OnLoad(Stream: PStream): Boolean;
//begin
//  //Result := uFMOD_PlaySong(
//  //                PAnsiChar(FileName), 
//  //                0, 
//  //                XM_FILE or XM_SUSPENDED
//  //              ) <> nil;
//  Result := False;
//end;

//function TXMPlayer.OnLoad(const FileName: TString): Boolean;
//begin
//  Result := uFMOD_PlaySong(
//                  PAnsiChar(FileName), 
//                  0, 
//                  XM_FILE or XM_SUSPENDED
//                ) <> nil;
//end;

//procedure TXMPlayer.OnPlay; 
//begin
//  uFMOD_Resume;
//end;

//procedure TXMPlayer.OnStop;
//begin
//  uFMOD_StopSong;
//end;

//procedure TXMPlayer.OnPause;
//begin
//  uFMOD_Pause;
//end;

//procedure TXMPlayer.SetVolume(Volume: Integer); 
//begin
//  FVolume := Volume;
//  uFMOD_SetVolume(uFMOD_MIN_VOL + Volume * uFMOD_MAX_VOL div DENG_MAX_VOLUME);
//end;

//function TXMPlayer.GetVolume: Integer;
//begin
//  Result := FVolume;
//end;
//{$IFNDEF FLAG_FPC}{$ENDREGION}{$ENDIF}
//{$IFNDEF FLAG_FPC}{$REGION 'TXMLoader'}{$ENDIF}
//function TXMLoader.Load(Stream: PStream): TMusicPlayer;
//begin
//  Result := TXMPlayer.Create;
//  if not Result.OnLoad(Stream) then begin
//      Result.Free;
//      Result := nil;
//  end;
//end;

//function TXMLoader.Load(const FileName: TString): TMusicPlayer;
//begin
//  Result := TXMPlayer.Create;
//  if not Result.OnLoad(FileName) then begin
//      Result.Free;
//      Result := nil;
//  end;
//end;
//{$IFNDEF FLAG_FPC}{$ENDREGION}{$ENDIF}

initialization
//  RegisterMusicLoader(TXMLoader.Create);
end.
