首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的音频没有在我的游戏记录在ReplayKit?

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

Stack Overflow用户
提问于 2016-04-06 17:11:02
回答 1查看 1.1K关注 0票数 1

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

代码语言:javascript
复制
@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")
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-09 02:18:18

好的,我已经开始工作了,但是我不得不使用AVAudioPlayer而不是MPMusicPlayerController。由于某些原因,replaykit不使用MPMedia录制音频。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36457884

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档