MPMoviePlayerController multitasking problem

后端 未结 3 1395
天涯浪人
天涯浪人 2021-01-06 06:22

I develop an application on iphone that uses MPMoviePlayerController to play audio file. When Application goes to background, if mpmovieplayer is playing, iphone continues t

相关标签:
3条回答
  • 2021-01-06 06:44

    You should read the Technical Q&A QA1668: How to play audio in the background with MPMoviePlayerController.

    Summary of the steps needed:

    • declare that your application supports background execution for audio
    • assign an appropriate category to your audio session (default category is not ok)
    0 讨论(0)
  • 2021-01-06 06:45

    may be you forget to add this in

     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
         {
        [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
       }
    
    0 讨论(0)
  • 2021-01-06 06:46

    I got it working by putting following two lines in Delegate file:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    [[AVAudioSession sharedInstance] setActive: YES error: nil];
    
    0 讨论(0)
提交回复
热议问题