replaykit startrecording有时永远不会进入完成处理程序 [英] replaykit startrecording sometimes never enters completion handler

查看:352
本文介绍了replaykit startrecording有时永远不会进入完成处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用重播工具包在游戏过程中保存我的屏幕视频但随时随机 startRecordingWithMicrophoneEnabled recorder.stopRecordingWithHandler 永远不会进入完成处理程序

I am using replay kit to save a video of my screen during gameplay but randomly on occasion startRecordingWithMicrophoneEnabled and recorder.stopRecordingWithHandler never enters the completion handler

它不会抛出错误,它只会无限期地运行并挂起。

it doesn't throw an error, it just runs and hangs indefinitely.

if recorder.available && recorder.microphoneEnabled {
    recorder.startRecordingWithMicrophoneEnabled(true) { [unowned self] (error) in
        if let unwrappedError = error {
            print(unwrappedError.localizedDescription)
        } else {
            print("called")
            self.manager.instructions.text = "Click to Start Game"
        }
    }
}

if recorder.available && recorder.microphoneEnabled {
    print("initiating stop recording")
    recorder.stopRecordingWithHandler { [unowned self] (RPPreviewViewController, error) in
        print("in completion handler")
        if let previewView = RPPreviewViewController {
            print("will transition to gameplay video")
            previewView.previewControllerDelegate = self
            self.presentViewController(previewView, animated: true, completion: nil)
            self.sessionHandler.session.stopRunning()
        }
    }
}


推荐答案

我遇到了同样的问题并且发现了它的原因(或者只是一个原因)。如果您的设备连接到无法访问互联网的WiFi,则会出现此问题。如果您将其连接到具有互联网接入或禁用WiFi的WiFi,它可以正常工作。我想在开始录制时,ReplayKit尝试连接到某些Apple服务器,但从未到达它们,也永远不会超时。您可以在App Store中观察到相同的行为。当您连接到没有互联网的WiFi时,它会尝试永久加载商店,永远不会超时。

I had the same problem and just found its cause (or maybe just a cause). If your device is connected to a WiFi that has no internet access this problem occurs. If you connect it to a WiFi that has internet access or disable WiFi it works just fine. I guess when starting a recording, ReplayKit tries to connect to some Apple servers but never reaches them and also never times out. You can observe the same behavior with the App Store. When you are connected to a WiFi without internet it tries to load the store forever and never times out.

这篇关于replaykit startrecording有时永远不会进入完成处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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