james forhand
james forhand

Reputation: 5

How to Manage Background Sound in iphone App?

I am playing a background sound using the AVAudioPlayer Framework. I have a play button and a pause button. It works, but whenever I switch views and return to the main menu, it stops working.

Upvotes: 0

Views: 314

Answers (2)

Nitin
Nitin

Reputation: 7471

-Measure your music run and then set NSTimer with music run time and set timer to the audio start method.pass your flag to the second view do same thing.

Upvotes: 1

user918958
user918958

Reputation: 92

set a loop , this probably means your music isnt long enough. say, //your avaudioplayer.numberOfLoops = -1

that will make it keep on going, music will only stop IF you it finishes if you change view and music is not done it should stil go on. But if you want background music from when you start the app put your avaudioplayer code with the loop inside your app delegate bool did finish launching with options and inherit the method to stop it in the other view e.g.

appDelegate *delegate = [[appDelegate alloc] init]; [appDelegate stop]; and make a stop method in the app delegate saying [music stop] or something like that

Upvotes: 0

Related Questions