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
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
.