Playing background music files in IOS background

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.