MPMoviePlayerController 多任务问题

发布于 2024-10-03 12:36:04 字数 290 浏览 0 评论 0原文

我在 iPhone 上开发一个应用程序,使用 MPMoviePlayerController 来播放音频文件。 当应用程序进入后台时,如果 mpmovieplayer 正在播放,iPhone 会继续播放当前音乐,但当播放结束时,下一首曲目不会开始。

我尝试在 MPMoviePlayerPlaybackDidFinishNotification 中启动下一个音频文件,当我使用调试器跟踪代码时,我可以看到该方法被调用并且代码被执行,但下一个音频文件仍然没有启动。

这在 iOS 4.1 上可行还是有限制?

此致 萨曼莎

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

辞取 2024-10-10 12:36:05

我通过在委托文件中添加以下两行来使其工作:

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

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

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
浅忆 2024-10-10 12:36:05

可能是你忘记添加这个

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

may be you forget to add this in

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
   }
孤独患者 2024-10-10 12:36:04

您应该阅读技术问答QA1668
如何使用 MPMoviePlayerController 在后台播放音频

所需步骤摘要:

  • 声明您的应用程序支持音频后台执行 为
  • 您的音频会话分配适当的类别(默认类别不行)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文