实现代码
编写的播放软件,慢慢地有了声音控制的需求,在网上找了一下,用Core Audio APIS 音频应用开发即可。入门稍慢,不过用起来很简单。整理了一个类供调用。
class TCbwAudioEndpointVolumeCallback;
typedef void __fastcall (__closure * TOnVoiceNotifyEvent)(bool bMuted, int fMasterVolume);
class TCbwVolumeControl {
private:
TCbwAudioEndpointVolumeCallback * EPVolEvents;
TOnVoiceNotifyEvent FOnVoiceNotify;
bool FValid;
bool __fastcall HRStatus(HRESULT hr, UnicodeString info);
void __fastcall Prework();
void __fastcall AfterWork();
in