IOS 4.0 and later support background playing. The following describes how to play a sound file. After the screen is closed, the sound file can still be played. The specific implementation method is as follows:
Add the following field to the plist file: The Declaration content is as follows: I
IOS 4.0 and later support background playing. The following describes how to play a sound file. After the screen is closed, the sound file can still be played. The specific implementation method is as follows:
Add the following fields to the plist file:
The statement is as follows:
Add the uibackgroundmodes key value to info. plist. It contains one or more string values, including
Audio: provides sound playing functions in the background, including audio streams and sounds during video playback.
Location: the user's location information can be maintained in the background.
VoIP: Use the VoIP function in the background
In the Program , add:
avaudiosession * session = [avaudiosession sharedinstance];
[session setactive: yes error: Nil];
[session setcategory: avaudiosessioncategoryplayback error: Nil];
declares that the sound runs in the background. Finally, run the program and close the program. The sound is played successfully in the background.