audio - iOS: retrieve volume from different 'routes' -


i want save current volume in application, accessible using [mpmusicplayercontroller ipodmusicplayer] , can listen different hardware 'routes' subscribing route change notifications (so can detect headphones, etc).

however, couldn't figure out how following; volume of both ios device , headphones @ once. right now, can retrieve volume of current active hardware route.

is there solution problem?

i'm not sure if enough of answer, best manage , retrieve volume of headphones when active route. compare volume prior.

to headphone volume when plugged in, can subscribe avaudiosessionroutechangenotification:

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(audioroutedidchange:) name:avaudiosessionroutechangenotification object:nil]; 

and comparing current volume in callback last recorded volume.

- (void) audioroutedidchange:(nsnotification*)notificaiton {     avaudiosessionroutechangereason routechangereason = [[notificaiton.userinfo valueforkey:avaudiosessionroutechangereasonkey] intvalue];              if (routechangereason == avaudiosessionroutechangereasonnewdeviceavailable) {         avaudiosessionroutedescription* route = [[avaudiosession sharedinstance] currentroute];         (avaudiosessionportdescription* desc in [route outputs]) {             if ([[desc porttype] isequaltostring:avaudiosessionportheadphones])                 [self saveheadphonevolume];         }     } } 

(this code work when headphones plugged in after app started, of course check route , volume before adding notification observer.)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -