I want to play a .mp3 file in an Objective-C app being designed for use on Mac OS X Lion 10.7, not for the iPhone. Thanks!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Take a look at the NSSound
class:
NSSound *sound = [[NSSound alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"mySound" ofType:@"mp3"] byReference:NO];
[sound play];
[sound release];