问题
Is there a way to programmatically mute the sound on OSX without using private APIs and in a way that is accepted by the Mac App Store.
回答1:
FOR MAC OS X: This tutorial might be of assistance.
FOR IOS: No.
Sound Mute is a system-wide setting. So for applications developed using the official SDK cannot change (and in most cases cannot even access) system-wide settings.
It is technically possible to change the system volume through the private AVSystemController
class in Celestial.framework
, but will prevent your app from getting Apple's approval.
回答2:
On the Mac, see Srikar's answer. I believe he's got it covered.
On iOS, [MPMusicPlayerController iPodMusicPlayer].volume = 0.0
will mute the audio output. If there is an MPVolumeView
present in your view hierarchy, it will do this without visual feedback; if there is not, it may present the volume change popup you see when you press the hardware volume buttons on the device.
来源:https://stackoverflow.com/questions/8431412/is-there-a-way-to-programmatically-mute-the-sound-on-osx