Any iPhone Devs that can help me out?
Hey!
It would mean one hell of allot if someone could help me out with this issue I have with my iOS app.
This is how it works. Its a simple game. When the app first launches, it launches into the ProjectNamesViewController.m and then the viewDidLoad method gets called.
In the viewDidLoad method, I call my configuration method which is a sender.
This is how my configuration method works:
-(void) configure:(id) sender{
NSString * pathToMusic = [[NSBundle mainBundle] pathForResource:@"MusicFile" ofType:@"m4a"];
backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusic] error:NULL];
backgroundMusic.delegate = self;
backgroundMusic.numberOfLoops = -1; // (So this keeps playing and not stopping even though it as at the end of the track.)
}
Then in my viewDidLoad method, the playMusic method gets called:
-(void) playMusic{
[backgroundMusic play];
}
I have multiple views in my app. One is settings, about and new game.
I want the music that is currently playing on the starting view to keep playing when I go onto settings and about. When I press new game I want it to stop the track that is playing on the starting view and then play the music on the new game view. I have no problem with this bit.
Here is the problem:
I start the app. Music plays, great. I press new game, where new game uses the same method of playing music as the main view does. It stops the main views music and plays its own. I can go back to the main menu and it stops its current playing music, and starts main views music.
This is where my problem comes in:
If I go onto another view before going onto New Game, I cannot stop the music playing on the main view.
Help?
I know this isnt a good sign of me being a good programmer. Im crap at it if I am honest. But I am not going to let that stop me. Il keep learning. I have been learning for a year or 2 so far, going okish I guess.
Anyway, I would be very very very very very very very very grateful if some one could help me out.
Thanks!
PS:
Wow, this is a little longer then I thought. Be warned: I do overcomplicate allot! ![]()
_________________
?Sometimes when you innovate, you make mistakes. It is best to admit them quickly, and get on with improving your other innovations.? -Steve Jobs.
