program Music01;

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

uses SysUtils,

     fwLogging,
     fwCustomEngine,
     fwPlattform;

const
  SCREEN_WIDTH     = 320;
  SCREEN_HEIGHT    = 240;
  SCREEN_BPP       = 16;

var
  Screen           : TfwCESurface;
  BackgroundMusic  : TfwCEMusic;
begin
  // Setze die Grafik - Engine 
  SetHAL(TfwEngine.Create(false, false));
  try
    Screen := HAL().Init(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);
    if Assigned(Screen) then begin
      // Lade die Musik
      BackgroundMusic := HAL().CreateMusic('../Media/music.mp3');	  
      BackgroundMusic.Play(60);
      while (not HAL().ExitKeyPressed()) do begin
        // Verwaltung fuer Ereignisse aufrufen
        HAL().Idle();
        HAL().UpdateInput();
      end;
    end;
  except
    on E : Exception do begin
      fwLog(E.Message);
    end;
  end;
end.
