Playing music in IOS background

Source: Internet
Author: User

1. // background playback
Avaudiosession * session = [avaudiosession sharedinstance];
[Session setactive: Yes error: Nil];
[Session setcategory: avaudiosessioncategoryplayback error: Nil];

2. Enable the background to Handle multimedia events
[[Uiapplication sharedapplication] beginreceivingremotecontrolevents];
Remote-control events originate as commands issued by headsets and external accessories that are intended to control multimedia presented by an application. To stop the operation of remote-control events, you must call endtransferingremotecontrolevents.

3. When the system is running in the backgroundProgramIt can run for a period of time. Use this method to get a certain amount of time and process some things after the program enters the background.
-(Uibackgroundtaskidentifier) beginbackgroundtaskwithexpirationhandler :( void (^) (void) Handler
This method lets your application continue to run for a period of time after it transitions to the background.
Your application cocould call this method to ensure that had enough time to transfer an important file to a remote server or at least attempt to make the transfer and note any errors. you shoshould not use this method simply to keep your application running after it moves to the background.

From: http://www.cnspirit.com /? P = 222

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.