• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mute System
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mute System


  • Subject: Re: Mute System
  • From: Keith Duncan <email@hidden>
  • Date: Wed, 12 Mar 2008 22:41:23 +0000

what i have to do to control the system Aduio Volume (mute, increase, decrease).

I use CoreAudio; AppleScript is too inefficient for my uses.

static OSStatus GetDefaultAudioDevice(AudioDeviceID *device) {
OSStatus status;

UInt32 size;
size = sizeof(*device);
status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, device);

return status;
}


- (void)setSystemVolume:(NSUInteger)volume {
OSStatus status;

AudioDeviceID device;
status = GetDefaultAudioDevice(&device);
require_noerr(status, ReturnStatus);

UInt32 size;

UInt32 channels[2];
size = sizeof(channels);
status = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyPreferredChannelsForStereo, &size, &channels);
require_noerr(status, ReturnStatus);

UInt32 mute = (volume == 0);
float systemVolume = volume/100.0;

for (NSUInteger index = 0; index < 2; index++) {
size = sizeof(mute);
status = AudioDeviceSetProperty(device, NULL, channels[index], false, kAudioDevicePropertyMute, size, &mute);
require_noerr(status, ReturnStatus);

size = sizeof(systemVolume);
status = AudioDeviceSetProperty(device, NULL, channels[index], false, kAudioDevicePropertyVolumeScalar, size, &systemVolume);
require_noerr(status, ReturnStatus);
}

ReturnStatus:

return;
}
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Mute System (From: Herr Thomas Bartelmess <email@hidden>)

  • Prev by Date: Ignore QTMovieView Inputs
  • Next by Date: How to make a UI like in Mail?
  • Previous by thread: Re: Mute System
  • Next by thread: Core Animation geometry, layer hosting, and resolution independence
  • Index(es):
    • Date
    • Thread