J'utilise le code suivant: Le son est placé mY dans myapp/Ressources partagées/background_music.aiffPas de musique de fond tout en jouant sur Xcode 4.2
@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
Il n'y a pas d'erreur et il n'y a pas de boucle dire sound.Kindly moi ce qui se passe.
Cordialement
Rien à voir avec le problème, mais l'utilisation de 'sleep (3);' dans 'didFinishLaunchingWithOptions' entraînera de gros problèmes. Parce que si votre application ne démarre pas assez vite, iOS la détruira. Il est préférable de superposer le rootviewcontroller à 'default.png' et de le supprimer lorsque votre application est complètement chargée. – rckoenes
@NSPostWhenIdle pas de son –
La journalisation de l'URL du son est-elle correcte? –