I am working on iphone app. I want to tap a button for playing an .wav file. then I want to check if the volume of iphone is mute then make it louder and play the .wav file. Is it possible programmatically?
I think you can do this....
http://iphoneincubator.com/blog/tutorial/how-to-play-audio-with-the-iphone-sdk
this link for audio play..
when you are able to play sound,then for mute the sound just write soundname.volume = 0;and when you want to up the volume then just write soundname.volume=5
I believe not. iOS only allows the "user" to change settings like these.
Even if it was possible, I would highly doubt if it would pass the App Store terms of publication.
You can try to check the volume by,
[[MPMusicPlayerController iPodMusicPlayer] volume];
set the volume by,
[[MPMusicPlayerController iPodMusicPlayer] setVolume: value];
Related
I am creating an app regarding movie player. In movie player I played videos. It worked fine but I want to mute the volume through coding. I want to set one button for volume mute. When I click the button it performs actions for mute. How can I proceed for this?
Hi there is no such mute option available. But you can set volume through codebase. Check this Apple documentation, it might be helpful to you:
http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMusicPlayerController_ClassReference/Reference/Reference.html
I am writing an iPad app that uses the "Flite" text-to-speech engine to announce specific events. The Flite engine uses an AVAudioPlayer instance to play the speech audio once it renders. For fun, I decided to add some simple controls to my app to allow the user to control iPod playback (next, prev, play/pause and volume - the basics) while my app is running using MPMusicPlayerController (of course).
The problem I am having is that when I adjust the iPod volume using MPMusicPlayerController, all of my audio is affected, including other sound effects and the speech audio. I set the volume for these other audio players (AVAudioPlayer instances) to 1.0 before playing the sound but it seems that the volume is always capped at whatever the iPod player volume is set to...
Is this normal? And what can I do to get around it? I want my app's audio to play at system full volume regardless of the volume level of the iPod player. (Example: The user had set the system volume to 80% of the device's max. I want my app to play audio at 100% of that 80% while allowing the user to adjust the iPod audio playback to 0-100% of that 80%.) Note: I am not interested in "ducking" but setting the iPod volume lower at all times while my app is running (background music).
I also have the problem, that -sometimes- when you first launch the app and press play on the iPod player (which sends the [player play] call), the iPod does not respond. If I press the home button, go into the iPod app and start playback then, once returning to my app, it works fine. What the deal with that?
Thanks in advance for any help!!
It could be something to do with the audio session category you've specified. Check out the Audio Session Programming Guide to see if you've chosen the right category.
The volume buttons on the side control the system volume and by extension the volume of your app's sounds.
I guess it's considered to be the Master volume control.
you can set the volume for specific samples or sounds using the AVItem's setVolume
[item setVolume]
You can create an AVItem to reference an existing sound file in your application or on the iphone. The code is pretty simple and looks like this -->
AVItem *item [[AVItem alloc]
initWithPath:#"the file"];
[item setVolume];
btw, this will not affect the rest of the audio channel (instantiated by some kinda AVController object) and the volume that you've set in your code will not be displayed on you screen so im not sure if you can change it at run time.
all, I want play sound even the iPhone in mute mode, but the method : [AVAudioPlayer setVolume] does not effect if the device is in mute mode ...
is it possible have some way to change the systemwide volume ?
thanks for your help ...
The recommended way to let the user set the system volume is with an MPVolumeView. The whole point of the mute button is that applications cannot play sounds, and there is no sanctioned way to override that.
I'm using the MPMusicPlayerController application music player, created like:
appMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];
The issue is that it will play music no matter which setting the device mute switch is in, it doesn't seem to care either way. Is there some audio session mode I need to be in to have it respect the mute switch?
Yes. You want to use one of the following constants for your Audio Session Category:
kAudioSessionCategory_AmbientSound
kAudioSessionCategory_SoloAmbientSound
These are the ones that go silent when the Ring/Silent switch is set to silent.
Fwiw I'm seeing the same problem. I suspect that, like the iPod app itself, it will never respect the mute switch.
Try using iPodMusicPlayer instead of applicationMusicPlayer.
So I have an app which plays many short sound clips. I need to know when the sounds are finished playing, and I need to use mp3s, so I'm using AVFoundation for the sound playback.
When a sound is actively playing, and the user uses the hardware volume buttons, the playback volume changes. Problem is, the app is NOT constantly playing sounds, and when it's not, and the hardware buttons are used, the RINGER volume gets adjusted instead.
How do I set it up so, as long as the app is running, the user can adjust the playback volume?
Thanks!
Turns out this can be accomplished by allocating an AVAudioPlayer with any valid sound file and calling the prepareToPlay method, without ever calling the play method.
Works perfectly.
Start an AudioSession and don't stop it when you're not playing sounds.
so you want to disable ringer playback volume as long as the app is running? therefore the hardware controls will only adjust the app playback sounds?
i dont think this is possible unless you are "always playing sound" for example, many games are always playing background music or what have you.
You might be able to accomplish this by constantly playing a 0 volume sound as long as your app is running. You could then play your sound clips over it.
How do I play multiple sounds simultaneously?