【问题标题】:RPScreenRecorder How recording screen audio and video of an app Action Extension?RPScreenRecorder 如何录制一个app Action Extension 的屏幕音视频?
【发布时间】:2018-02-11 18:43:15
【问题描述】:

我想用目标Action Extension录制我的应用的屏幕、音频和视频。

如果我将此代码放在普通应用程序中,它可以工作,但在操作扩展中则不行。

@IBAction func recButton(_ sender: Any) {


        if recButton.currentTitle == "stop" {
            stopRecording()
            recButton.setTitle("rec", for: .normal)
        }
        else {

            recButton.setTitle("stop", for: .normal)

            RPScreenRecorder.shared().isMicrophoneEnabled = true
            RPScreenRecorder.shared().startRecording(handler: {[unowned self] (error) in

            //Handler - never called
            if let unwrappedError = error {
                print(unwrappedError.localizedDescription)
            }
        })
        }
    }

    func stopRecording() {
        RPScreenRecorder.shared().stopRecording(handler: {(previewController, error) -> Void in

            //Handler - never called
            if previewController != nil {
                let alertController = UIAlertController(title: "Recording", message: "Do you want to discard or view your recording?", preferredStyle: .alert)

                let discardAction = UIAlertAction(title: "Discard", style: .default) { (action: UIAlertAction) in
                    RPScreenRecorder.shared().discardRecording(handler: { () -> Void in
                        // Executed once recording has successfully been discarded
                    })
                }

                let viewAction = UIAlertAction(title: "View", style: .default, handler: { (action: UIAlertAction) -> Void in
                    self.present(previewController!, animated: true, completion: nil)
                })

                alertController.addAction(discardAction)
                alertController.addAction(viewAction)

                self.present(alertController, animated: true, completion: nil)

            } else {
                // Handle error
            }
        })
    }

是否有另一种方法可以使用 AVCaptureSession 来实现这一目标,还是我需要使用其他方法来实现这一目标?谢谢。

【问题讨论】:

  • 这个问题让我对这个概念很感兴趣!我不确定您要伤心地做什么,但您可能想要研究的是Broadcast Extension 目标。这可能会有所帮助:)

标签: ios iphone swift replaykit rpscreenrecorder


【解决方案1】:

我很确定 Apple 不会让您按设计这样做。对于扩展程序,它们通常非常严格,无论是在 api 方面允许的内容还是通过应用审核的内容。

即使你想出了一个解决ReplayKit问题的老生常谈的解决方案,我想它也会被应用审查拒绝。

在一般的App Review Guidelines 中,app extension programming guide 被引用为定义指南,其中对于操作扩展它特别指出:

在 iOS 中,Action 扩展:

  • 帮助用户以不同的方式查看当前文档
  • 始终出现在操作表或全屏模式视图中
  • 仅当主机应用明确提供时才接收选定的内容

不太确定屏幕录制如何以说服 Apple 的方式融入该模式...

【讨论】:

  • 感谢回复。我的应用程序“帮助用户以不同的方式查看当前文档”就像一个文本阅读,现在,我只想记录阅读的文本。 AV或其他可以吗?
  • 当 ReplayKit 在应用程序扩展中不起作用,但在应用程序本身中起作用时,我认为这是按照一般设计(扩展不能调用录制框架)。所以我认为没有任何建议的解决方案可以做到这一点......
  • 据我了解,这应该是可能的。但是,我不确定如何在 Message Extension 应用程序中执行此操作。我正在努力,如果能够做到,我会尽快通知您。
【解决方案2】:

我不认为这是不可能的,因为我在 App Store 上看到了一些应用程序,它们在 iMessage 扩展应用程序中录制视频和音频。 Like : SuperMoji App 这个应用程序记录面部表情和音频 并仅在 iPhone 的消息应用程序中作为视频消息发送。

但是,我不确定如何在扩展应用程序中执行此操作。我正在努力,很快就会通知您。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-30
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多