我正在做一个猜歌游戏应用程序,我需要在用户猜时记录屏幕并捕获设备的音频输出。我希望我的应用程序支持ios8,因此“ReplayKit”不在桌面上,那么我应该使用哪个SDK?
我是一个初学者,如果有示例代码,将提供更多帮助,谢谢。
最佳答案
使用Apple的ReplayKit,您可以让用户记录游戏玩法,或者根据用户的情况进行记录。
包括WWDC 2015演示文稿的链接here
使用以下功能开始和停止记录:
func startRecording() {
let recorder = RPScreenRecorder.shared()
recorder.startRecordingWithMicrophoneEnabled(true) { [unowned self] (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Stop", style: .Plain, target: self, action: "stopRecording")
}
}
}
func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopRecordingWithHandler { [unowned self] (preview, error) in
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .Plain, target: self, action: "startRecording")
if let unwrappedPreview = preview {
unwrappedPreview.previewControllerDelegate = self
self.presentViewController(unwrappedPreview, animated: true, completion: nil)
}
}
}