gpt4 book ai didi

ios - 为什么我的游戏中的音频没有记录在 ReplayKit 中?

转载 作者:行者123 更新时间:2023-11-28 08:41:04 25 4
gpt4 key购买 nike

我使用 MPMusicPlayerController 在我的应用程序中播放音频,我使用 RPScreenRecorder 录制屏幕。我遇到的问题是它只记录屏幕而不记录应用程序中的音频。我遇到的另一个问题是,当我按下 previewController 的取消按钮时,它不会因为某种原因关闭 View 。我究竟做错了什么?

@IBAction func stopTheRecordingAction(sender: AnyObject) {

stopTheRecording.hidden = true
recordButton.hidden = false


RPScreenRecorder.sharedRecorder().stopRecordingWithHandler { (previewController: RPPreviewViewController?, error: NSError?) -> Void in

if previewController != nil {

let alertController = UIAlertController(title: "Recording", message: "Do you wish to discard or view your gameplay recording?", preferredStyle: .Alert)

let discardAction = UIAlertAction(title: "Discard", style: .Default) { (action: UIAlertAction) in
RPScreenRecorder.sharedRecorder().discardRecordingWithHandler({ () -> Void in
// Executed once recording has successfully been discarded
})
}

let viewAction = UIAlertAction(title: "View", style: .Default, handler: { (action: UIAlertAction) -> Void in
self.presentViewController(previewController!, animated: true, completion: nil)


})

alertController.addAction(discardAction)
alertController.addAction(viewAction)

self.presentViewController(alertController, animated: true, completion: nil)

} else {

// Handle error
}
}
}

@IBAction func recordScreen(sender: AnyObject) {
recordButton.hidden = true
stopTheRecording.hidden = false

if RPScreenRecorder.sharedRecorder().available {
RPScreenRecorder.sharedRecorder().startRecordingWithMicrophoneEnabled(true, handler: { (error: NSError?) -> Void in
if error == nil { // Recording has started

} else {
// Handle error
}
})
} else {
// Display UI for recording being unavailable

}

}




func previewControllerDidFinish(previewController: RPPreviewViewController) {
previewController.dismissViewControllerAnimated(true, completion: nil)
print("dismiss")
}

最佳答案

好的,我成功了,但我不得不使用 AVAudioPlayer 而不是 MPMusicPlayerController。出于某种原因,replaykit 不使用 MPMedia 录制音频。

关于ios - 为什么我的游戏中的音频没有记录在 ReplayKit 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36457884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com