Music Background playback: three stepsimplemented in the Didenterbackground method in Appdelegate:
The Beginbackgroundtaskwithexpirationhandler method of the app
Turn on background tasks to let the program run in the background
-(void) Applicationdidenterbackground: (uiapplication *) application{ //Use the method to release shared resources, Save user data, invalidate timers, and store enough application state information to restore your application to its Curre NT State in case it is terminated later. If your application supports background execution, this method is called instead of Applicationwillterminate:when the User quits. Background play one of three steps: Let the app run in the background [application Beginbackgroundtaskwithexpirationhandler:nil];}
"33_ sound-info.plist" in the Supporting files directoryAdd a "Required background modes"the value is "APP plays audio or streams audio/video using AirPlay"
third, the initialization method of the tool class "
Initialize, set the type of the audio session and activate
+ (void) initialize{ //Background play, step three, set audio session type avaudiosession *session = [avaudiosession sharedinstance]; Type: Play and record [session Setcategory:avaudiosessioncategoryplayandrecord Error:nil]; and to activate the audio session [session Setactive:yes Error:nil];}
the other three commonly used audio session types are:
Ios_33_ Music Background playback