使用ReplayKit在我的iOS应用程序处于后台时的屏幕录像 [英] Screen recording when my iOS app is in background with ReplayKit

查看:929
本文介绍了使用ReplayKit在我的iOS应用程序处于后台时的屏幕录像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了广播扩展.我已经通过target添加了该扩展名.但是,我不知道如何在我的应用程序处于后台时进行记录.

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:

通过控制中心:选择该名称后,我可以看到我应用的目标名称,然后单击Start Broadcast开始录制,然后单击Stop Record,但是我的视频没有显示存储在Camera Roll或我的应用中. Ref Link: ReplayKit的RPSystemBroadcastPickerView未显示preferredExtension

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

通过我的应用程序:按开始按钮开始录制后,我正尝试通过单击主屏幕按钮来录制我的应用程序的背景,显然录制已停止. Ref Link: https://medium.com/@giridharvc7/replaykit-screen-录音8ee9a61dd762 .

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.

推荐答案

在后台运行视频时,没有直接"方式将视频存储在您的应用中. ReplayKit版本2允许您在名为广播上载扩展"的应用扩展中获取视频样本缓冲区.当您说通过控制中心"时,它意味着您开始广播(而不是录制),同时iOS找到您的应用程序扩展名(而不是您的应用程序)并启动它,然后开始将视频样本缓冲区发送到该扩展名.在此步骤中,您需要决定如何处理这些缓冲区.

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.

但是您需要知道广播扩展是为缓冲区传输而设计的,而不是为了存储或重新渲染或压缩或重新编码缓冲区.扩展程序有很多限制,取决于CPU时间和内存使用情况(±50 MB),您可以在那里尝试执行任何操作,但是如果操作繁重,iOS将关闭扩展程序.

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.

这篇关于使用ReplayKit在我的iOS应用程序处于后台时的屏幕录像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆