MPMoviePlayer停止在后台播放

时间:2014-10-15 12:15:55

标签: ios

需要使用MpMoviePlayerController在后台播放音频。我知道我必须使用此代码来实现这一目标:

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

并在pList中设置“RequireBakgroundMode”。

这项工作正常,但当我将我的应用程序置于后台时,声音停止,我必须打开控制中心并按下播放才能恢复播放。

所以我的问题是,当应用程序进入后台时,如何避免声音停止?感谢

1 个答案:

答案 0 :(得分:2)

您的项目功能集。当应用程序在后台输入时,工作正常。

enter image description here

当你进行启用模式时,然后在plist文件中自动设置后台模式。

enter image description here