MPMoviePlayerViewController, playing video's sound in background

独自空忆成欢 提交于 2019-12-23 06:12:50

问题


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:


  1. you must detach audio stream for background mode
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!