Re: Double Beep
Re: Double Beep
- Subject: Re: Double Beep
- From: Dave <email@hidden>
- Date: Thu, 14 Aug 2003 21:53:25 -0400
How do I make a double system beep.
Two NSBeep()'s don't work since it only plays one beep.
Thanx.
SD.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
Hello,
One way to do it would be to use an NSTimer. In this example, beepTimer
is an instance variable.
-----
- (void)awakeFromNib
{
beepTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.2 target:
self selector: @selector(beepTwice) userInfo: nil repeats: YES] retain];
}
- (void)beepTwice
{
static int numberOfBeeps = 0;
NSBeep();
if (++numberOfBeeps == 2)
{
[beepTimer invalidate];
[beepTimer release];
}
}
-----
Note that this example will work differently with different alert
sounds (set in the System Prefs, Sound panel). A safe delay for the
NSTimer would be about half a second, but this may sound too long for
other alert sounds (such as Funk, whereas half a second is good for
Blow). You may just want to settle with 0.3, 0.35, or 0.4.
Dave
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.