MPMoviePlayerController multitasking problem

不想你离开。 提交于 2019-12-19 03:50:06

问题


I develop an application on iphone that uses MPMoviePlayerController to play audio file. When Application goes to background, if mpmovieplayer is playing, iphone continues to play the current music, but when it ends, the next track doesn't start.

I try to start the next audio file in the MPMoviePlayerPlaybackDidFinishNotification and when I follow the code using the debugger I can see that the method is invoked and the code executed, bat the next audio file still doesn't start.

Is this possible on iOS 4.1 or this is a limitation?

Best regards Samantha


回答1:


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)



回答2:


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

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];



回答3:


may be you forget to add this in

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
   }


来源:https://stackoverflow.com/questions/4224823/mpmovieplayercontroller-multitasking-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!