Reputation: 11782
I am using following code: 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
There are no errors and there is no looping sound.Kindly tell me what is going on.
Best Regards
Upvotes: 0
Views: 451
Reputation: 11782
ok i added [background play];
and it has started working fine..... that wasn't mentioned in the tutorial which i was following..
Upvotes: 2
Reputation: 977
player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.movieSourceType = MPMovieSourceTypeStreaming;
if(player.playbackState == MPMoviePlaybackStatePlaying)
[player stop];
[player play];
Upvotes: 0