我正在使用以下代码:my Sound is placed in myapp/Shared Resources/background_music.aiff
@synthesize window = _window;
- (void)dealloc
{
[backgroundSound release];
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
sleep(3);
//this variable can be named differently
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/background_music.aiff",[[NSBundle mainBundle] resourcePath]]];
NSError *error;
backgroundSound = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
backgroundSound.numberOfLoops = -1;
//>> this will allow the file to //play an infinite number of times */
return YES;
}
@interface AppDelegate : UIResponder <UIApplicationDelegate>{
AVAudioPlayer *backgroundSound;
}
@property (strong, nonatomic) UIWindow *window;
@end
没有错误,也没有循环声音。请告诉我发生了什么。
最好的祝福