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
Related
I have an iPhone app that plays tracks through an AVPlayer, and separately want button click sounds. I first used AVAudioPlayer for the clicks and this works fine except I don't want the 'Play' icon in the status bar to appear every time the user clicks a button and the click sample is played.
I turned my attention to System Sounds, which I read has limitations in that you cannot directly set the volume. However, I am seeing strange volume behaviour which makes me wonder if I can:
NSURL *clickURL = [[NSBundle mainBundle] URLForResource:#"click" withExtension:#"wav"];
SystemSoundID clickSoundID;
AudioServicesCreateSystemSoundID((CFURLRef)clickURL, &clickSoundID);
AudioServicesPlaySystemSound(clickSoundID);
If I click a button before playing a track the volume is set to the phone ringer volume. However, after playing a track using AVPlayer the volume is set to the player volume (as I would like it to be).
Any ideas how I can make the System Sound sample take on the app volume level regardless of if AVPlayer has been in action first? Alternatively is there a way to disable play icon notifications in the status bar?
You need to set the correct AVAudioSession. There is one called solo ambient which will not do the play button I think. Can't be more detailed at the moment, because I'm on my phone. (will fix later with a more fuller description)
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];
I am working on the game. And I have some issue with sounds.
I use system sounds to acknowledge a player, when he/she presses a button. These sounds respect the volume set by a player, when other sounds are playing (I use AVAudioPlayers and AudioQueues). But when a system sound is only to play, it ignore a volume set by player and plays at a ringer's volume.
How to force system sounds to respect a volume set by a player even when is no other sounds played?
Assuming you are meaning that players are setting the volume using the side volume buttons on the device:
I had the same problem getting SystemSound to respect the volume buttons but found a setting in "Settings"/"Sounds"/"Ringer and Alerts"/"Change With Buttons" that was "OFF" by default. Switching that to "ON" made it work.
How are your players (I assume you mean the people playing the game) setting the volume -- through the device's volume control, or through your app interface? If the latter, then this won't work, since system sounds should always play at the device volume.
According to the Multimedia Programming Guide, "Sounds play at the current system audio volume, with no programmatic volume control available."
I don't know why your system sounds would change volume when an AVAudioPlayer sound is playing. If that's the case, can you loop a silent sound with AVAudioPlayer when you're not playing other sounds? Otherwise I would try playing all sounds with AVAudioPlayer so that you have direct control over the volume.
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.
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?