.xm and .s3m file doesn't play in BASS library from Inno Setup, only .mp3

后端 未结 1 1753
长发绾君心
长发绾君心 2021-01-16 17:16

When I choose .mp3 file, it will play when launching setup.exe but when I change it to .xm or .s3m, it doesn\'t play



        
相关标签:
1条回答
  • 2021-01-16 18:00

    Indeed, the BASS_StreamCreateFile returns 0 for both files.

    And if you call BASS_ErrorGetCode afterwards, it returns 41 = BASS_ERROR_FILEFORM (unsupported file format).

    function BASS_ErrorGetCode(): Integer;
      external 'BASS_ErrorGetCode@files:bass.dll stdcall';
    
    SoundStream := BASS_StreamCreateFile(...);
    if SoundStream = 0 then
    begin
      Log(Format('Error playing file, error code = %d', [BASS_ErrorGetCode]));
    end;
    

    But as you correctly hinted, you should use the BASS_MusicLoad for MO3 / IT / XM / S3M / MTM / MOD / UMX formats.

    type
      HMUSIC = DWORD;
    
    function BASS_MusicLoad(
        mem: BOOL; f: string; offset: Int64; length, flags, freq: DWORD): HMUSIC;
        external 'BASS_MusicLoad@files:bass.dll stdcall';
    

    Replace the BASS_StreamCreateFile call with:

    BASS_MusicLoad(
      False, ExpandConstant('{tmp}\tune.xm'), 0, 0,   
      EncodingFlag or BASS_SAMPLE_LOOP, 0)
    

    Semantically, your should also rename the SoundStream variable to Music or similar; and change its type to HMUSIC.

    0 讨论(0)
提交回复
热议问题