Monday, 15 August 2011

ios - change UIBackgroundModes audio at runtime -



ios - change UIBackgroundModes audio at runtime -

i have app plays music, , want enable background modes. sound category set kaudiosessioncategory_mediaplayback , if add together audio string in uibackgroundmodes within info.plist file keeps playing audio. far good.

now want give alternative users, take if sound plays in background or not. tried getting file , deleting key far nil happens. did (in selector handled uibutton) :

-(void) disablebackgroundaudio:(uibutton*)button{ nsdictionary *plistdict = [[nsbundle mainbundle] infodictionary]; [plistdict setvalue:@"" forkey:@"uibackgroundmodes"]; }

if print value in console, before , after, can see had "audio" before, , after called, blank string. however, if force home button sound playing no matter if disabled audio.

my guess not way update (although i'm not sure if it's possible) info.plist file. possible @ all? after think giving users selection improve specific app, , i've seen other apps doing it.

any help appreciated.

the info.plist part of application's bundle. all files in bundle immutable.

keep audio value there , pause music when application enters background (in case user turned alternative off).

ios info.plist

1 comment: