3

我正在寻找一些将当前 MacOSX 系统上每个可用声音资源的名称输出到 NSLog 的 Objective-C 代码。我做了很多谷歌搜索。我错过了一些关键术语,因为搜索没有发现任何有用的东西。只要我知道如何在 Mac OS 中播放声音?.

// Assumes #import <AppKit/AppKit.h> and the framework has been added. 
NSSound *sound = [[NSSound alloc] initWithContentsOfFile:    [[NSBundle mainBundle] pathForResource:@"Fark" ofType:@"mp3"] byReference:NO];
[sound play];
[sound release];
4

1 回答 1

2

查看文档+[NSSound soundNamed:],您会发现该方法将在查看应用程序的主包后搜索以下目录:

~/Library/Sounds
/Library/Sounds
/Network/Library/Sounds
/System/Library/Sounds

因此,这些可能是寻找机器上可用系统声音的好地方。

"every available Sound resource on the current MacOSX system" is a rather tall order, depending on what you mean. The system sounds will likely be found in the directories described above, but there may also be sounds inside applications that you might or might not consider to be part of the operating system.

于 2012-10-18T01:02:12.180 回答