2016-11-07 10 views
1

このコードはBass Audio Library on/off Buttonから「ミュート」に変更する方法はありますか?Inno SetupのBASSライブラリでオーディオをミュートするには

変更する必要はありますか?

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; 

procedure SoundCtrlButtonClick(Sender: TObject); 
begin 
    case BASS_ChannelIsActive(SoundStream) of 
    BASS_ACTIVE_PLAYING: 
    begin 
     if BASS_Pause then 
     SoundCtrlButton.Caption := 
      ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOn}'); 
    end; 
    BASS_ACTIVE_PAUSED: 
    begin 
     if BASS_Start then 
     SoundCtrlButton.Caption := 
      ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}'); 
    end; 
    end; 
end; 

procedure InitializeWizard; 
begin 
    ExtractTemporaryFile('tune.mp3'); 
    if BASS_Init(-1, 44100, 0, 0, 0) then 
    begin 
    SoundStream := BASS_StreamCreateFile(False, 
     ExpandConstant('{tmp}\tune.mp3'), 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; 
+0

質問が分かりません。 *「一時停止」*テキストを「ミュート」*テキストに変更するだけですか?または、実際にメディアを一時停止するのではなく、ボリュームを0%に設定して、「ミュート」機能を実装したいのですか?しかし、それは音声のみのメディア(.mp3)で意味をなさないでしょうか? - とにかく、あなたのコードは私のために働く。 - あなたの '[Files]'セクションを表示してください。 'bass.dll'は何を使いましたか? –

+0

''ミュート '機能、ボリュームを0%に設定する '、可能ですか?私は[un4seen](http://www.un4seen.com/) 'bass.dll'を使用します。 – DDoS

+0

私の答えを見てください。しかし、まず、すでに作業しているコードを作成する必要があります。そこに何か問題があります。しかし、それは別の話題です。わたしにはできる。 –

答えて

1

、音量レベルを制御するoptionセットとBASS_SetConfigを使用するには、例えば作成し、 "ストリーム" の

SoundCtrlButtonClickは、同じ名前の関数の一時停止/再開の実装をあなたの質問から置き換えたものです。

var 
    Muted: Boolean; 

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

Ahm ..これは申し訳ありませんが、[スクリプト](https://drive.google.com/open?id=0BzPmkOR1ZhRfczU4c3BldWpxMHc)にコードを挿入する必要があります。 – DDoS

+0

'SoundCtrlButtonClick(Sender:TObject)プロシージャの代わりに。 .... end; 'ブロック。 –

+0

私の実装が複雑すぎることに気付きました。私の編集された答えを見てください。 –

関連する問題