ReplayKit返回错误"RPRecordingErrorFailedToStart". [英] ReplayKit returns error "RPRecordingErrorFailedToStart"

查看:323
本文介绍了ReplayKit返回错误"RPRecordingErrorFailedToStart".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ReplayKit将录制功能添加到基于C ++的游戏中.我在游戏代码中检查iOS版本是否为9.0或更高版本,如果是9.0,则将调用RecordReplayIOS::startRecording(),然后ReplayKit应该开始记录.

I am trying to include recording functionality to my C++ based game with ReplayKit. I check that the iOS version is 9.0 or above in my game code, and if it is, I will call RecordReplayIOS::startRecording() and then the ReplayKit should start recording.

由于某些原因,startRecordingWithMicrophoneEnabled函数始终返回错误-5803,根据API文档,该错误表示RPRecordingErrorFailedToStart.有什么想法我做错了吗?

For some reason the startRecordingWithMicrophoneEnabled function returns always an error -5803, which according to API documentation means RPRecordingErrorFailedToStart. Any ideas what I am doing wrong?

RecordReplayIOS.hpp:

#ifndef __RECORD_REPLAY_IOS_HPP__
#define __RECORD_REPLAY_IOS_HPP__

class RecordReplayIOS {
public:
    static bool canRecord();
    static void startRecording();
    static void stopRecording();
};

#endif

RecordReplayIOS.mm:

#include "RecordReplay_ios.hpp"
#include "ReplayKit/ReplayKit.h"

@interface Recorder : NSObject
+(void)startRecording;
+(void)stopRecording;
@end

#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

bool RecordReplayIOS::canRecord() {
    // ReplayKit needs at least iOS 9
    if (SYSTEM_VERSION_LESS_THAN(@"9.0")) {
        return false;
    }
    return true;
}

void RecordReplayIOS::startRecording() {
    [Recorder startRecording];
}

void RecordReplayIOS::stopRecording() {
    [Recorder stopRecording];
}

@implementation Recorder

+(void)startRecording {
    RPScreenRecorder* recorder = RPScreenRecorder.sharedRecorder;
    recorder.delegate = self;
    [recorder startRecordingWithMicrophoneEnabled:false handler:^(NSError * error) {
        if(error != nil) {
            NSString* desc = error.description;
            return;
        }
    }];
}

+(void)stopRecording {
    RPScreenRecorder* recorder = RPScreenRecorder.sharedRecorder;
    [recorder stopRecordingWithHandler:^(RPPreviewViewController *previewViewController, NSError *error) {
        if(error != nil) {
            NSString* desc = error.description;
            return;
        }
        if(previewViewController) {
            //do stuff...    
        }
    }];
}

@end

推荐答案

代码没有错.似乎我只是尝试将ReplayKit与过旧的iPad一起使用.显然ReplayKit需要A7或A8处理器.我的具有A6处理器的iPad 4根本无法与ReplayKit一起使用.

There is nothing wrong with the code. It seems that I just tried to use ReplayKit with an iPad which was too old. Apparently ReplayKit needs either A7 or A8 processor. My iPad 4 which has A6 processor simply does not work with ReplayKit.

检查设备是否可以使用ReplayKit的正确方法是查询RPScreenRecorder.sharedRecorder.available.如果设备支持ReplayKit,则返回true.

The correct way to check if the device can use ReplayKit is to query RPScreenRecorder.sharedRecorder.available. It returns true if the device supports ReplayKit.

这篇关于ReplayKit返回错误"RPRecordingErrorFailedToStart".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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