iPod mini controls disabled when certain audio session parameters are set - iphone

I'm working on a music visualizer for the iPhone/iPad, under iOS 3 you could double-tap the home button and get iPod controls. With the latest version 4.1-4.2, these controls are now grayed out when the home button is pressed. I found a similar complaint at http://openradar.appspot.com/8696944, although there wasn't a solution.
I have the base sound category set to kAudioSessionCategory_PlayAndRecord, with kAudioSessionProperty_OverrideCategoryMixWithOthers set to true. (Just to add more fun to the problem I'm using OpenAL for some sound effects.)
I have tried setting the category back to ambient when the application goes into the background. but either it happens too late or it's not sufficient.

Here's where I've got to so far:
AudioSessionInitialize(NULL, NULL, NULL, self);
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
devicetwo = alcOpenDevice(NULL);
contexttwo = alcCreateContext(devicetwo, 0);
//The following two lines are the lines that gray out iPod controls:
alcMakeContextCurrent(contexttwo);
AudioSessionSetActive(YES);
The iPod controls remain grayed out even once the app quits... And removing the two culprit lines of code result in no sound being produced in the app.

Well I've given up.. I'm now coding my own UI based off of the AddMusic example code
http://developer.apple.com/library/ios/#samplecode/AddMusic/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40008845-Intro-DontLinkElementID_2
I'm happy to report that play and stop via the MPMusicPlayerController doesn't seem to conflict with the play and record session settings. And building your own play/pause/FF seems to be fairly straightforward
p.s. I've also discovered that this Music Visualizer app: http://itunes.apple.com/us/app/music-visualizer/id337651694?mt=8 is just this addMusic sample uploaded and this guy is charging 2 bucks for it.. It's got awful reviews.. but it still seems wrong that it's on the app store.

My iPod touch 4G is running iOS 4.2, and it doesn't have this problem. I would attempt to contact Apple.

Related

HTML Video plays with sound only through earphones -iOS?

I have developed a sencha-phonegap application which comprise of playing videos already present in the application.
When I play any other video such as a video song through the native player, audio is heard perfectly from the stereo speakers present at the bottom.
I am simply using the xtype: video tag to play the video. Here's my code to play the video:
{
xtype : 'video',
x : 0,
y : 0,
left :'0px',
top :'0px',
width : 175px,
height : 98px,
url : "path of video"
posterUrl: 'placeholder.png'
}
The problem which I am facing is that whenever the video is played, it only plays with sound when the earphones are connected and sometimes the audio can also be heard from the top-speaker (the speaker used during calls).
I have checked for the ringer and volume controls. Everything is at maximum.
My app supports iOS versions 5.0 and above.
Could this be iOS related issue?
Kindly provide some direction.
Thanx
Please first add Audio Toolbox and AVFoundation frameworks if not added already and than import class in which you add the below lines on app launch
#import<AVFoundation/AVFoundation.h>
than add these two lines in your project when you app launches
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
May be it will work now.
On one of sencha forum, I found This Link Which Helped Me.
Since, it only specifically mentions about ringer off scenario, it also mentions in generic way that we need to add playback method for sound to work.
Cheers |m|

Setting allows airplay to no still sends sound over airplay

I am working with a media player, some media does not have the right to be played over Airplay, don't ask why :). So when I get that media, I set
movieplayerController.allowsAirplay = NO;
If you were playing with airplay before, it is then on by default next time. By doing the code above, you will get the movie playing on your device, but the sound audio route is still sent over airplay. I have tried to overwrite the audio route, but it doesn't budge, seems like Airplay trumps all.
If I could just disable airplay, my problem would be solved, but I can't find anywhere a way to do that.
This looks similar to this question. The answer mentions that the AirPlay button should always be visible to send audio.

App vibrating but ring tone is not playing when makes app in sleep mode manually. iphone

Im implementing a fake call app.Im using a NSTimer for checking the time and it is working fine.The problem is when we press the sleep button,only vibration is working but ring tone is not playing.I tried this code but still ring tone is not playing.
AudioSessionSetActive(true);
// Set up audio session, to prevent iPhone from deep sleeping, while playing sounds
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (
kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory
);
How can i solve this issue.please help.Thanks in advance
I am sorry but I think You can not show calling screen while device locked (deep sleep). The only way is to fire local notification to wake up your application manually by user. Something like : You have fake call now. Do you want to receive ? So when user press Yes and it will open your application and you will need to handle to show calling screen in appDelegate background methods.
I played with other Fake Call apps and they are doing same. We are not allowed to do any UI Changes in background. So this is the only way to achieve your goal to display calling screen.
Hope this help.
Edit:
I am not sure why vibrate is working. Did you set below property in your info.plist file ? Just to give it try. Not sure that will solve your problem. Just give it a try once. See attache picture. Set Required Background modes to App Plays Audio.

MPMoviePlayerController and AVAudioPlayer audio mixing glitch

I'm developing an interactive storybook type application for the iPhone and I've recently encountered a frustrating bug concerning audio mixing on the device.
Firstly, I setup an audio session. I set the category to AVAudioSessionCategoryAmbient and then init and play my AVAudioPlayer instance. Now, in the background whilst the audio is playing I'm pre-loading a video to play using an MPMoviePlayerController followed by a call to prepareToPlay. The reason I pre-load the video this way is because I need it to play instantly later on cue with fairly strict timing.
In this configuration, the audio/movie works fine and they mix and do not interrupt each other. However, this particular audio session category does not permit audio to continue playing while the device is locked, a feature I really need. As a result I'm forced to consider a different category: AVAudioSessionCategoryPlayback.
By default this category does not permit mixing with other audio, according to the Apple docs. To enable mixing with other audio I am overriding the relevant category:
OSStatus propertySetError = 0;
UInt32 setProperty = 1;
propertySetError = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(setProperty), &setProperty);
assert(propertySetError == 0);
Unfortunately, this solves my playing whilst locked issue but introduces another issue: the AVAudioPlayer audio is interrupted briefly as the video loads with a minor stutter. The stutter is small, perhaps less than a second but is enough to disrupt the user experience. I've read this related post which enabled me to pre-load the video with the AVAudioSessionCategoryAmbient, but unfortunately the same approach doesn't seem to work with the new category.
The audio session category is applied successfully, according to the return code. Does anyone know why enabling audio mixing with this category is not the same as the mixing facility provided by ambient category?
The best way I've found working a similar problem is to use the newer AVPlayer (+1 #adam) and set your app to enable background audio and receive remote control notifications. I was tipped off to this by #MarquelV following How can you play music from the iPod app while still receiving remote control events in your app?
If you can get backgrounding working properly, that should enable you to continue playing while the device is locked. Oh, and don't forget to add keys to info.plist, its easy to do and then have no idea why it isn't working.

iPhone SDK audioSession question

In my app i record and play audio at the same time. The app is almost finished. But there is one thing, that annoying me. When audio session is set to PlayAndRecord, sounds become quiet in comparison with the same sounds with the SoloAmbient category. Is there any way to make sound louder using PlayAndRecord?
when you use the session for play and record, the playback comes out of the speaker used for the phone, otherwise it comes out the speaker located at the bottom of the phone. this is to prevent feedback. you can override this like so (but watch out for feedback, not an issue if you aren't doing both at once)
//when the category is play and record the playback comes out of the speaker used for phone conversation to avoid feedback
//change this to the normal or default speaker
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);
this code works on 3.1.2, earlier sdk's you have to do differently.
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
status = AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);
you have to be careful with this method, it will override even if you have headphones plugged in, you have to monitor interruptions and change the routes accordingly. much better now using 3.1.2
Ask the user to plug in headphones?
The headphone + mic combination doesn't suffer from this problem.
I don't know if it's a bug, a consequence of the audio hardware,
or if the quiet playback is just an intentional and hamfisted
way of getting cleaner recordings.
UPDATE
I found out that setting the PlayAndRecord session changes your audio route to the receiver.
Apparently the use case is for telephony applications where the user holds the device up to his ear.
If that doesn't violate the Principle of Least Surprise, I don't know what does.