title: Play a sound only in a specific page in Inno Setup
body: <p>I'm creating a installer for my application with Inno Setup. I use BASS audio library to play music in background of the installer.</p>
  <p>Here is my code for playing the sound.</p>
  <pre class="lang-pascal prettyprint-override"><code>[Code]
  const
    DI_NORMAL = 3;
    FR_PRIVATE = $10;  {added to compact Mode}
    BASS_SAMPLE_LOOP = 4;
    BASS_ACTIVE_STOPPED = 0;
    BASS_ACTIVE_PLAYING = 1;
    BASS_ACTIVE_STALLED = 2;
    BASS_ACTIVE_PAUSED  = 3;
    BASS_UNICODE = $80000000;
    BASS_CONFIG_GVOL_STREAM = {#MusicVolume};
    EncodingFlag = BASS_UNICODE;
    #if CheckCRC == &quot;1&quot;
    PM_REMOVE = 1;
    WM_QUIT   = 18;
    #endif
  
  function BASS_Init(device: LongInt; freq, flags: DWORD; win: HWND; clsid: Cardinal): BOOL;
    external 'BASS_Init@files:bass.dll stdcall';
  function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD; offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
    external 'BASS_StreamCreateFile@files:bass.dll stdcall';
  function BASS_Start: BOOL;
    external 'BASS_Start@files:bass.dll stdcall';
  function BASS_Pause: BOOL;
    external 'BASS_Pause@files:bass.dll stdcall';
  function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
    external 'BASS_ChannelPlay@files:bass.dll stdcall';
  function BASS_SetConfig(option: DWORD; value: DWORD ): BOOL;
    external 'BASS_SetConfig@files:bass.dll stdcall';
  function BASS_ChannelIsActive(handle: DWORD): DWORD;
    external 'BASS_ChannelIsActive@files:bass.dll stdcall';
  function BASS_Free: BOOL;
  
  procedure MusicButtonClick(Sender: TObject);
  begin
    case BASS_ChannelIsActive(SoundStream) of
      BASS_ACTIVE_PLAYING:
      begin
        if BASS_Pause then
          MusicButton.Caption := ExpandConstant('{cm:MusicButtonCaptionSoundOn}');
      end;
      BASS_ACTIVE_PAUSED:
      begin
        if BASS_Start then
          MusicButton.Caption := ExpandConstant('{cm:MusicButtonCaptionSoundOff}');
      end;
    end;
  end;
  
  ExtractTemporaryFile('{#MusicFile}');
  if BASS_Init(-1, 44100, 0, 0, 0) then
  begin
    SoundStream := BASS_StreamCreateFile(False,
    ExpandConstant('{tmp}\{#MusicFile}'), 0, 0, 0, 0,
    EncodingFlag or BASS_SAMPLE_LOOP);
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
    BASS_ChannelPlay(SoundStream, False);
  end;
  </code></pre>
  <p>i want to play a sound only in a page of my installer (in this case licence page)
  i want when the user come in <strong>license page</strong>, normal music <strong>stop</strong> and other sound start play,after finish this sound music <strong>start</strong> play again
  and also there is anyway to disable <strong>next</strong> button until sound end?</p>
  <p>thanks</p>
  <hr />
  <p>With Martin Prikryl's help, I've edited my code a little. My code now like this (again I can't put full code on post because it has many lines)</p>
  <pre class="lang-pascal prettyprint-override"><code>procedure InitializeWizard();
  var
    SoundStream: HSTREAM;
    LicenseSoundStream: HSTREAM;
    //-some other code-//
    IniFile := ExpandConstant('{tmp}\Settings.ini');
    #if Music == &quot;1&quot;
    if BASS_Init(-1, 44100, 0, 0, 0) then
      begin
        BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
        ExtractTemporaryFile('{#MusicFile}');
        ExtractTemporaryFile('lic.mp3');
        SoundStream :=
          BASS_StreamCreateFile(
            False, ExpandConstant('{tmp}\{#MusicFile}'), 0, 0, 0, 0,
            BASS_UNICODE or BASS_SAMPLE_LOOP);
        LicenseSoundStream :=
          BASS_StreamCreateFile(
        False, ExpandConstant('{tmp}\lic.mp3'), 0, 0, 0, 0, BASS_UNICODE);
        BASS_ChannelPlay(SoundStream, False);
      end;
    #endif
  
  </code></pre>
  <pre class="lang-pascal prettyprint-override"><code>procedure CurPageChanged(CurPageID: integer);
  begin
    //-some other code-//
    #if UseLicense == &quot;1&quot;
    if CurPageID = wpLicense then
    begin
      AboutButton.Hide;
      WizardForm.DirEdit.Hide;
      WizardForm.DirBrowseButton.Hide;
      WizardForm.GroupEdit.Hide;
      WizardForm.GroupBrowseButton.Hide;
      WizardForm.PageNameLabel.Hide;
      WizardForm.PageDescriptionLabel.Hide;
      WizardForm.UserInfoNameLabel.Hide;
      WizardForm.UserInfoNameEdit.Hide;
      if Assigned(LicenseSoundStream) then
      begin
        BASS_ChannelPlay(LicenseSoundStream, True);
        BASS_Start;
      end;
    end
      else
    begin
      { On other pages, restore the standard music }
      if Assigned(SoundStream) then
      begin
        BASS_ChannelPlay(SoundStream, False);
      end;
    end;
    #endif
  end;
  </code></pre>
  <p>its now give me compiler error in <code>if Assigned(LicenseSoundStream)</code>, error is <code>Line 4416: Column 17: Unknown identifier 'LicenseSoundStream'</code></p>
  <hr />
  <p>-edit 2-</p>
  <p>as you know i have 2 sound in installer</p>
  <ol>
  <li>is background music (its play in whole installer page except license page)</li>
  <li>is license page sound (when user inter license page background sound pause and other sound play, and when exit other sound start play again)</li>
  </ol>
  <p>im add button to disable and enable background sound with this codes</p>
  <pre class="lang-pascal prettyprint-override"><code>procedure MusicButtonClick(Sender: TObject);
  begin
    case BASS_ChannelIsActive(SoundStream) of
      BASS_ACTIVE_PLAYING:
      begin
        if BASS_Pause then
          MusicButton.Caption := ExpandConstant('{cm:MusicButtonCaptionSoundOn}');
      end;
      BASS_ACTIVE_PAUSED:
      begin
        if BASS_Start then
          MusicButton.Caption := ExpandConstant('{cm:MusicButtonCaptionSoundOff}');
      end;
    end;
  end;
  </code></pre>
  <p>but my problem is if user pause background sound before inter license page, inside license page background sound play again (instead of other sound)</p>