现在可以在iOS 11上录制屏幕吗?

时间:2017-06-07 07:01:42

标签: swift3 ios11

今天我看到一些videos苹果提供了在控制中心录制屏幕的选项。

我很好奇它是否也可供开发人员使用?

我用谷歌搜索但没有找到任何与此相关的文档。有人可以对这个话题有所了解。

1 个答案:

答案 0 :(得分:9)

应用屏幕分享 根据API文档中的新更新,您可以捕获Video&仅通过您的应用的屏幕音频。

enter image description here

RPScreenRecorder 共享记录器对象,可以记录您应用的音频和视频。

通过此课程,您可以录制您的应用程序屏幕,并通过iPhone麦克风绑定Audion。

以下是一些可用于录制具有不同不同选项的屏幕的方法。

访问共享记录器:

class func shared()

控制应用程序录制:

-- Starts recording the app display.
func startRecording(handler: ((Error?) -> Void)? = nil)

-- Stops the current recording.
func stopRecording(handler: ((RPPreviewViewController?, Error?) -> Void)? = nil)

-- Starts screen and audio capture.
func startCapture(handler: ((CMSampleBuffer, RPSampleBufferType, Error?) -> Void)?, completionHandler: ((Error?) -> Void)? = nil)

-- Stops screen capture
func stopCapture(handler: ((Error?) -> Void)? = nil)

希望这可以帮助您捕捉应用中的屏幕。

参考链接:https://developer.apple.com/documentation/replaykit/rpscreenrecorder

文档参考:https://developer.apple.com/library/content/releasenotes/General/WhatsNewIniOS/Articles/iOS_11_0.html

  

延迟发布,但对于仍在搜索相关内容的人可能会有用   问题

iPhone屏幕共享:

我在共享屏幕上做了一些R& D并提出了以下更新。

WWDC 2017 Session 606

涵盖所有细节我们实际想要分享/广播或捕获我们的iOS设备屏幕的音频和放大器视频。

Apple介绍ReplyKit2屏幕截图&共享。

广播代码:

  1. 创建RPScreenRecorder的对象:

    让broadCastController = RPBroadcastController() 让录音机= RPScreenRecorder.shared()

  2. 使用startBroadcasting()方法开始广播:

  3.     func startBroadcasting() {
                RPBroadcastActivityViewController.load { broadcastAVC, error in
                    guard error == nil else {
                        print("Cannot load Broadcast Activity View Controller.")
                        return
                    }
    
                    if let broadcastAVC = broadcastAVC {
                        broadcastAVC.delegate = self
                        self.present(broadcastAVC, animated: true, completion: nil)
                    }
                }
          }
    
    1. 使用以下活动控制器方法选择要广播的应用。
    2. func broadcastActivityViewController(_ broadcastActivityViewController: RPBroadcastActivityViewController,
                                               didFinishWith broadcastController: RPBroadcastController?,
                                               error: Error?) {
              guard error == nil else {
                  print("Broadcast Activity Controller is not available.")
                  return
              }
      
              broadcastActivityViewController.dismiss(animated: true) {
                  broadcastController?.startBroadcast { error in
                      //TODO: Broadcast might take a few seconds to load up. I recommend that you add an activity indicator or something similar to show the user that it is loading.
                      if error == nil {
                          print("Broadcast started successfully!")
                          self.broadcastStarted()
                      }
                  }
              }
          }
      
      1. 使用stopBroadcasting()停止广播:
      2. func stopBroadcasting() {
                broadCastController.finishBroadcast { error in
                    if error == nil {
                        print("Broadcast ended")
                        self.broadcastEnded()
                    }
                }
        }
        

        希望这个最新的更新有所帮助!

        将很快更新......