How to play background music with MPMusicPlayerController's applicationMusicPlayer in iOS?

StackOverflow https://stackoverflow.com/questions/14291333

Вопрос

Hello i am trying to play background music with MPMusicPlayerController's applicationMusicPlayer in iOS.

I have also added Required background modes in Plist.

But it doesn't play background music.

How can i play background music with MPMusicPlayerController?

Thanks for your reading. :)

Это было полезно?

Решение

The applicationMusicPlayer does not support background music. Use MPMusicPlayerController's iPodMusicPlayer instead. It shares the state with the built-in iPod player and music will continue to play when your app enters the background.

Другие советы

Bryan is right about applicationMusicPlayer not playing music in background, but there is another solution:

You can use AVAudioPlayer to play either streamed or local(bundle) audio. It even allows you to play multiple audio file at the same time having an AVAudioPlayer instance for each.

Here's the documentation: http://developer.apple.com/library/ios/#DOCUMENTATION/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top