How do you add a Mute Button/Volume Slider when using AVAUDIOPLAYER...
How do you add a Mute Button/Volume Slider when using AVAUDIOPLAYER... I have an app with 20 sound buttons across four tabs. I need to add a volume slider for each tab or a mute button for each tab. I also wanted to know if there is a way to set how loud a sound button can be. For Example if I have the following Button:
How do you add a Mute Button/Volume Slider when using AVAUDIOPLAYER... I have an app with 20 sound buttons across four tabs. I need to add a volume slider for each tab or a mute button for each tab. I also wanted to know if there is a way to set how loud a sound button can be. For Example if I have the following Button:
And I want this sound button to play at the half the volume compare to other audio buttons what do I do ?
The docs say that AVAudioPlayer has a volume property. It doesn't say if it allows you to change the volume while a sound is playing or not, but I think it probably does.
You need to create a slider in IB, and connect to an action with for the UIControlEventValueChanged event. In that action method, get the value of the slider and set the volume property of your audio player.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I have serveral buttons that play sound and execute other code. If I want to add a mute button must I create a IABACTION and then add theAudio.volume = 0; for every button.
I have serveral buttons that play sound and execute other code. If I want to add a mute button must I create a IABACTION and then add theAudio.volume = 0; for every button.
Create a single IBAction and connect all your mute buttons to the same action.
If each mute button is supposed to mute a different sound, but tags on the buttons, and have the action get the tag value and use that to figure out which sound to mute.
(Make your action look like this:
Code:
- (IBAction) muteButtonAction: (id) sender;
{
int button_tag;
button_tag = [sender tag];
//Figure out which sound to mute based on the tag
}
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
hi i am working on a single view based app ,and was wondering in xcode 4.2 can you apply this code under the -(void)viewDidLoad so when the app starts up background music can play?
hi i am working on a single view based app ,and was wondering in xcode 4.2 can you apply this code under the -(void)viewDidLoad so when the app starts up background music can play?
BTW, you should put the sound player object into a property so you can stop it, adjust the volume, etc. If you just create it as a local variable, you have no way to reference the audio player object once you exit your viewDidLoad method.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
BTW, you should put the sound player object into a property so you can stop it, adjust the volume, etc. If you just create it as an instance variable, you have no way to reference the audio player object once you exit your viewDidLoad method.
I think you mean a local variable.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.