我正在尝试包括录制功能到我的C++为基础的游戏与ReplayKit。我检查游戏代码中的iOS版本是9.0或更高,如果是的话,我会调用RecordReplayIOS::startRecording(),然后ReplayKit应该开始录制。
由于某些原因,startRecordingWithMicrophoneEnabled函数总是返回一个错误-5803,根据API文档,这意味着RPRecordingErrorFailedToStart。你知道我做错了什么吗?
RecordReplayIOS.hpp
#ifndef __RECORD_REPLAY_IOS_HPP__
#define __RECORD_REPLAY_IOS_HPP__
class RecordReplayIOS {
public:
static bool canRecord();
static void startRecording();
static void stopRecording();
};
#endifRecordReplayIOS.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发布于 2015-11-10 10:09:59
代码没有什么问题。似乎我只是尝试将ReplayKit与一个太老的iPad一起使用。显然,ReplayKit需要A7或A8处理器。我的iPad 4有A6处理器,它根本不适用于ReplayKit。
检查设备是否可以使用ReplayKit的正确方法是查询RPScreenRecorder.sharedRecorder.available。如果设备支持ReplayKit,则返回true。
https://stackoverflow.com/questions/33613763
复制相似问题