我想在我的应用程序启动时播放音频,但首先,音频不播放!不管我如何编码。其次,如果可以的话,我很想循环播放它。
@implementation ViewController
-(void)awakeFromNib
{
SystemSoundID soundID;
NSString *soundFile1 = [[NSBundle mainBundle] pathForResource:@"ScaryMusic" ofType:@"mp3"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef) [NSURL fileURLWithPath:soundFile1], &soundID);
AudioServicesPlaySystemSound(soundID);
NSLog(@"Sound Played");
}