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%,而不是实际暂停媒体?但是这对于纯音频媒体(.mp3)没有意义,对吧? - 无论如何,你的代码适合我。 - 向我们展示你的'[Files]'部分。你使用了什么'bass.dll'? –
“静音”功能,将音量设置为0%,这有可能吗?我使用[unseseen](http://www.un4seen.com/)'bass.dll' – DDoS
请参阅我的答案。但首先,你需要编写你已经有效的代码。你有一些问题。但这是一个不同的话题。这个对我有用。 –