iUser
iUser

Reputation: 1075

How can i stop all audio file with single button?

I am making a quiz app and i have set different background music in two UIView.
Now i have created button for stop the bachgrond music.

IBOutlet UIButton *soundoffbtn;  

I stop the background music for firstview by

-(Void)SoundBtn{
[Avbackmusic stop];
}

It just stop in one view.
When i entered in secondView , background music for that view is started as it should be.

What i want is to stop the background music for whole app (both view) by just tapping the firstview's soundoffbtn

What should i do for that?
I am new to this..
Any help will be appreciated..

Thanks.

Upvotes: 0

Views: 128

Answers (1)

Denis Kutlubaev
Denis Kutlubaev

Reputation: 16124

I didn't fully understand a question. But if you want the second view not to start playing sound after you switch off sound on first view then create an indicator variable in applicaton delegate that will indicate the sound on/off status for your app. Access that indicator before playing a sound. If it shows on, then play, if off, do not play. For example in your app delegate create a variable

int soundIndicator;
@property (nonatomic) int soundIndicator;
@synthesize soundIndicator;

Then in your View controllers you can access that variable, it will be common for all application:

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.soundIndicator == 0){ ... } 

Upvotes: 2

Related Questions