Friday 15 March 2013

ipod - How to programmatically detect earpiece in iphone? -


I am currently working on a project that involved in playing music from iphone music library within the application. I am using MPMediaPickerController to allow the user to choose his music and play it using the iPod music player within the iPhone.

However, I insert the user into my earpiece and remove it when the problem occurred. Music will suddenly stop playing for no reason. After some testing, I came to know that the iPod player will stop playing after the device unplugs its earpiece. So is there any way to programmatically detect whether the earpiece has been unplugged so that I can start playing music? Or is there any way to stop the ipod player from stopping user unplug your earpiece?

How do you change notification AudioRoute must register and introduce you want to handle getaway changes

  changes // register audio path listener callback function AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, self);  

Within the callback, you may cause the rerouting

  CFDictionaryRef routeChangeDictionary = inPropertyValue; CFNumberRef routeChangeReasonRef = CFDictionaryGetValue (routeChangeDictionary, CFSTR (kAudioSession_AudioRouteChangeKey_Reason)); CIT 32 Way Change Reversion; CFNumberGetValue (Route Change Regener, KCFNumberCIT32 Type, and Route ChangeResionation); If (routeChangeReason == kAudioSessionRouteChangeReason_OldDeviceUnavailable) if (routeChangeReason == kAudioSessionRouteChangeReason_NewDeviceAvailable) is plugged into {// headset ..} is {// headset unplugged ..}  
< / Html>

No comments:

Post a Comment