Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

KardelSharpeye

macrumors member
Original poster
Apr 28, 2009
56
0
Good morning all,

I am trying to play the intro sound for an application. However the sounds always play before the first screen ever loads. Even if I execute the play sound function after I have load/initialize all my views. Is there any event I can listen to like AS3.0 ( Event.addedToStage)? or anyway I can do so that the sound plays after the intro screen is visible to user?

Thanks all.
 
Put your code in the viewDidAppear method of your view controller where you want to play the sound. It gets called immediately after the view has appeared and become visible.
 
Put your code in the viewDidAppear method of your view controller where you want to play the sound. It gets called immediately after the view has appeared and become visible.

yeh so here is my code

Code:
- (void)viewDidLoad {
myView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) viewController:self];

[self.view addSubview:myView];

[introSound play];
}

and i also tried viewDidAppear but if i tell it to play the sound in here i get nothing...
 
viewDidLoad != viewDidAppear

haha yeah sorry i saw that...but yeh i managed to get the sound play in viewDidAppear but it is still a second early before myView is visible.

Code:
- (void)viewDidAppear:(BOOL)animated {
   [introSound play];
}
 
Instead of playing the sound in the viewDidAppear method of the superview, why not try playing it in the viewDidAppear method of the MyView?
 
Instead of playing the sound in the viewDidAppear method of the superview, why not try playing it in the viewDidAppear method of the MyView?

hmm yeh i tried that i think its only called in the view controller.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.