Screen recording when my iOS app is in background with ReplayKit

人盡茶涼 提交于 2019-11-27 07:26:49

问题


I have tried Broadcast Extension. I have added that extension via target. But, I don't know how to record when my app is in background.

Two ways I am trying to record:

Via Control center: I can see my app’s target name, after selecting that name, then I start to record by clicking Start Broadcast, next by clicking Stop Record, but my video not getting stored either in Camera Roll or in my app. Ref Link: ReplayKit's RPSystemBroadcastPickerView not showing preferredExtension

Via my app: Once press Start button, recording get started, I am trying to record background from my app by clicking home button, obviously recording has been stopped. Ref Link: https://medium.com/@giridharvc7/replaykit-screen-recording-8ee9a61dd762.


回答1:


There is no "direct" way to store video in your app while it is in the background. ReplayKit version 2 allows you to get video sample buffer pieces in the app extensions that calls "Broadcast Upload Extension". When you say "Via Control center" it means that you start broadcast (not recording), and at the same time iOS finds your app-extension (not your application) and launch it, then begins send video sample buffers to the extension. On this step you need to decide what to do with these buffers.

I can propose two solutions for you:

  • you can try transfer buffers to the server (and download video when main application will be launched)
  • you can try save buffers to the file using App Groups (to share this data with the main application), you can find example here.

But you need to know that broadcast extension has been designed for buffer transferring, not to store or re rendering or compress or recode buffers. Extension has a lot of limitations based on CPU time and Memory usage (±50 MB), you can try to do anything there but if it is "heavy" operation iOS will close the extension.



来源:https://stackoverflow.com/questions/54485367/screen-recording-when-my-ios-app-is-in-background-with-replaykit

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