问题
I'm playing the video stream with MPMoviePlayerViewController
.
In my app's info.plist
I have set UIBackgroundModes
to audio
.
When I press home button while playing video playback is paused, after going back to application playback continues again.
It works out of the box without having to change something.
But in some applications (e.g. Jasmine) when I press Home button video's sound playing is continued in background.
So I have 2 questions:
1) What's the magic? How to play video's sound in background without showing video stream itself? I can't find any working solutions.
2) If it is hard to implement, can I leave everything as it is? I have set UIBackgroundModes
to audio
without actually playing audio in background, so I assume my app has chances to be rejected on review stage. Am I right? Or for video streaming applications setting UIBackgroundModes
is allowed even if nothing is playing in background?
Thanks in advance.
回答1:
- you must detach audio stream for background mode
- your app will be rejected, for sure. I seach the technical solution too ;)
回答2:
You need to set your audio session category. Have a read through the documentation here:
- Audio Session Basics (Note the "What Is an Audio Session Category?" section
- Audio Session Categories
来源:https://stackoverflow.com/questions/12760314/mpmovieplayerviewcontroller-playing-videos-sound-in-background