Re: List of AppKit NSSound names
Re: List of AppKit NSSound names
- Subject: Re: List of AppKit NSSound names
- From: Ryan Britton <email@hidden>
- Date: Thu, 27 Oct 2005 08:16:59 -0700
From what I've found, there doesn't appear to be a way to query for
a sounds list. Here's the code I use to build a sound list:
#define SystemLibrary() @"/System/Library/"
#define AllUsersLibrary() @"/Library/"
#define UserLibrary() [NSHomeDirectory()
stringByAppendingPathComponent:@"Library/"]
#define SoundsDirectory(base) [base
stringByAppendingPathComponent:@"Sounds"]
NSArray *knownSoundTypes = [NSSound soundUnfilteredFileTypes];
searchPaths = [NSArray arrayWithObjects:
SoundsDirectory(SystemLibrary()),
SoundsDirectory(AllUsersLibrary()),
SoundsDirectory(UserLibrary()),
nil];
e = [searchPaths objectEnumerator];
while (soundDirectory = [e nextObject])
{
if ([fm fileExistsAtPath:soundDirectory isDirectory:&isDir])
{
if (isDir)
{
fileEnum = [[fm
directoryContentsAtPath:soundDirectory] objectEnumerator];
while (soundFile = [fileEnum nextObject])
{
if ([knownSoundTypes containsObject:[soundFile
pathExtension]])
{
[sounds addObject:[soundFile
stringByDeletingPathExtension]];
}
}
}
}
}
sortedSounds = [[sounds allObjects]
sortedArrayUsingSelector:@selector(compare:)];
On Oct 27, 2005, at 8:03 AM, Tim Gogolin wrote:
The documentation for NSSound says the name may be
"One of the named system sounds provided by the Application Kit"
By experimentation, I see that the names "Tink", "Basso", etc. (from
the Sound Preferences Panel) work fine as sound names. I wish to
construct a popup menu with these predefined sounds, but I feel
nervous about hardcoding the list... Is there documentation that lists
a minimum set of sound names that will always be present? Or is there
an API that gives me a list of sounds names? NSSound.h doesn't seem
to mention either, nor does a google search come up with much.
-- Tim Gogolin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden