2016-11-07 10 views
1

.mp3 파일을 선택하면 setup.exe를 실행할 때 재생되지만 .xm 또는 .s3m으로 변경하면, 그것은.xm 및 .s3m 파일은 Inno Setup의 BASS 라이브러리에서만 재생됩니다. .mp3

[Setup] 
AppName=Bass Audio Project 
AppVersion=1.0 
DefaultDirName={pf}\Bass Audio Project 

[Files] 
Source: "Bass.dll"; Flags: dontcopy 
Source: "tune.xm"; Flags: dontcopy 

[CustomMessages] 
SoundCtrlButtonCaptionSoundOn=Play 
SoundCtrlButtonCaptionSoundOff=Mute 

[Code] 
const 
    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 = 5; 
const 
    #ifndef UNICODE 
    EncodingFlag = 0; 
    #else 
    EncodingFlag = BASS_UNICODE; 
    #endif 
type 
    HSTREAM = DWORD; 

function BASS_Init(device: LongInt; freq, flags: DWORD; 
    win: HWND; clsid: Cardinal): BOOL; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD; 
    offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_Start: BOOL; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_Pause: BOOL; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_SetConfig(option: DWORD; value: DWORD): BOOL; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_ChannelIsActive(handle: DWORD): DWORD; 
    external '[email protected]:bass.dll stdcall'; 
function BASS_Free: BOOL; 
    external '[email protected]:bass.dll stdcall'; 

var 
    SoundStream: HSTREAM; 
    SoundCtrlButton: TNewButton; 
    Muted: Boolean; 

procedure SoundCtrlButtonClick(Sender: TObject); 
begin 
    if not Muted then 
    begin 
    if BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 0) then 
    begin 
     SoundCtrlButton.Caption := 'Play'; 
     Muted := True; 
    end; 
    end 
    else 
    begin 
    if BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500) then 
    begin 
     SoundCtrlButton.Caption := 'Mute'; 
     Muted := False; 
    end; 
    end; 
end; 

procedure InitializeWizard; 
begin 
    ExtractTemporaryFile('tune.xm'); 
    if BASS_Init(-1, 44100, 0, 0, 0) then 
    begin 
    SoundStream := BASS_StreamCreateFile(False, 
     ExpandConstant('{tmp}\tune.xm'), 0, 0, 0, 0, 
     EncodingFlag or BASS_SAMPLE_LOOP); 
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500); 
    BASS_ChannelPlay(SoundStream, False); 

    SoundCtrlButton := TNewButton.Create(WizardForm); 
    SoundCtrlButton.Parent := WizardForm; 
    SoundCtrlButton.Left := 8; 
    SoundCtrlButton.Top := WizardForm.ClientHeight - 
     SoundCtrlButton.Height - 8; 
    SoundCtrlButton.Width := 40; 
    SoundCtrlButton.Caption := 
     ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}'); 
    SoundCtrlButton.OnClick := @SoundCtrlButtonClick; 
    end; 
end; 

procedure DeinitializeSetup; 
begin 
    BASS_Free; 
end; 

어떻게해야합니까 재생되지 않습니다? 나는 원본 파일에 .xm 또는 .s3m이고 변환 된 것은 .mp3이 아닌 파일에 사용하고 싶다.

Un4seen에서 볼 수 있듯이 bass.dll은 .xm 및 .s3m을 지원합니다.

+0

[XMPlay] (http://support.xmplay.com/)에있는 파일을 좋을 수 있습니까? –

+0

** 재생 ** 파일을 의미합니까? [screenshot] (http://i.imgur.com/1Z3LoXW.png) – DDoS

+0

파일을 우리와 공유 할 수 있습니까? –

답변

2

사실 BASS_StreamCreateFile은 두 파일 모두에 대해 0을 반환합니다.

나중에 BASS_ErrorGetCode을 호출하면 41 = BASS_ERROR_FILEFORM (지원되지 않는 파일 형식)을 반환합니다.

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

그러나 제대로, 암시, 당신은 MO3/IT/XM/S3M/MTM/MOD/UMX 형식에 대한 BASS_MusicLoad을 사용해야합니다.

type 
    HMUSIC = DWORD; 

function BASS_MusicLoad(
    mem: BOOL; f: string; offset: Int64; length, flags, freq: DWORD): HMUSIC; 
    external '[email protected]:bass.dll stdcall'; 

가 함께 BASS_StreamCreateFile 전화 교체 : 의미 적

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

을, 당신은 Music 또는 유사한로 SoundStream 변수의 이름을 변경한다; 유형을 HMUSIC으로 변경하십시오.

+0

mp3 파일을 사용할 수 있습니다. 감사! – DDoS

+0

BASS 라이브러리는 이러한 형식을 지원해야합니다. 그러나 라이브러리에서 지원하지 않는 특정 파일에는 특정 코덱, 플래그 또는 무언가가있을 수 있습니다. –

+0

'BASS_StreamCreateFile' 대신'BASS_MusicLoad'을 사용하는 것이 어떻습니까? – DDoS