[英]How to play background music with MPMusicPlayerController's applicationMusicPlayer in iOS?
Hello i am trying to play background music with MPMusicPlayerController's
applicationMusicPlayer
in iOS. 您好我正在尝试在iOS中使用
MPMusicPlayerController's
applicationMusicPlayer
播放背景音乐。
I have also added Required background modes
in Plist. 我还在Plist中添加了
Required background modes
。
But it doesn't play background music. 但它不播放背景音乐。
How can i play background music with MPMusicPlayerController
? 如何使用
MPMusicPlayerController
播放背景音乐?
Thanks for your reading. 谢谢你的阅读。 :)
:)
The applicationMusicPlayer
does not support background music. applicationMusicPlayer
不支持背景音乐。 Use MPMusicPlayerController
's iPodMusicPlayer
instead. 请改用
MPMusicPlayerController
的iPodMusicPlayer
。 It shares the state with the built-in iPod player and music will continue to play when your app enters the background. 它与内置的iPod播放器共享状态,当您的应用程序进入后台时,音乐将继续播放。
Bryan is right about applicationMusicPlayer not playing music in background, but there is another solution: Bryan对于applicationMusicPlayer不在后台播放音乐是正确的,但还有另一种解决方案:
You can use AVAudioPlayer to play either streamed or local(bundle) audio. 您可以使用AVAudioPlayer播放流式或本地(捆绑)音频。 It even allows you to play multiple audio file at the same time having an AVAudioPlayer instance for each.
它甚至允许您同时播放多个音频文件,每个文件都有一个AVAudioPlayer实例。
Here's the documentation: http://developer.apple.com/library/ios/#DOCUMENTATION/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html 这是文档: http : //developer.apple.com/library/ios/#DOCUMENTATION/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.