2014-09-29 51 views
0

我已經面對,女巫簡單quoestion,我沒有在谷歌,或在任何論壇中找到。如何關閉應用程序音頻/聲音?像靜音?我不想讓複選框女巫控制應用程序的聲音。可可Mac OSX應用程序關閉聲音

我將詳細定義感謝

回答

0

試試這個從source code

- (void)setDefaultAudioDevice 
{ 
    UInt32 propertySize = 0; 
    OSStatus status = noErr; 
    AudioObjectPropertyAddress propertyAOPA; 

    propertyAOPA.mElement = kAudioObjectPropertyElementMaster; 
    propertyAOPA.mScope = kAudioObjectPropertyScopeGlobal; 
    propertyAOPA.mSelector = kAudioHardwarePropertyDefaultOutputDevice; 
    propertySize = sizeof(AudioDeviceID); 

    status = AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject, &propertyAOPA, 0, NULL, &propertySize, &outputDeviceID); 

    if(status) 
    { 
     // Error 
     return; 
    } 
} 

- (void)muteHardwareVolume 
{ 
    UInt32 propertySize = 0; 
    OSStatus status = noErr; 
    AudioObjectPropertyAddress propertyAOPA; 

    [self setDefaultAudioDevice]; 

    propertyAOPA.mElement = kAudioObjectPropertyElementMaster; 
    propertyAOPA.mScope = kAudioDevicePropertyScopeOutput; 

    propertyAOPA.mSelector = kAudioDevicePropertyMute; 

    propertySize = sizeof(UInt32); 
    UInt32 mute = 1; 
    status = AudioHardwareServiceSetPropertyData(outputDeviceID, &propertyAOPA, 0, NULL, propertySize, &mute); 

    if(status) 
    { 
     // Error 
     return; 
    } 
} 
+0

海蘭,感謝重播,它的失敗「propertyAOPA」 undentified,您添加了這麼多的代碼,但basicly如果有任何命令,如[NSApp setmute:True]或[VLCAudio setvolume:0];在OSX 10.9上使用libvlc。我知道有簡單的命令,關閉 – RepoStack 2014-09-30 05:31:06

+0

嗨!我沒有看到像[NSApp setmute:True]或[VLCAudio setvolume:0]之類的內容,僅適用於QTMovie或AVPlayer,但不適用於系統。爲了正確編譯示例,您需要包含框架#import 並聲明outputDeviceID – toohtik 2014-09-30 08:56:16

+0

您能否解釋如何聲明outputDeviceID? , – RepoStack 2014-09-30 09:54:49

相關問題