2016-11-07 4 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

関連する問題