2017-01-10 59 views
1

我在我的应用程序中使用replaykit,并且在用户完成录制之后,我提供了一个用于“共享”视频的按钮。我提供了RPPreviewViewController,如果我点击视频中的播放,当我回到应用时,音频不起作用。只有当我回到之前的viewController并回到录制的那个时,它才会起作用。RPPreviewViewController在播放后禁用音频

我的应用程序是一个音乐作曲应用程序,所以音频非常重要。我甚至试过正在重置的AVAudioSession类别回放视图驳回像这样经过:

func showPreview() { 
    if let unwrappedPreview = self.preview { 
     unwrappedPreview.previewControllerDelegate = self 
     self.present(unwrappedPreview, animated: true, completion: nil) 
    } else { 
     let alert = UIAlertController(title: "No recordings to share", message: "By hitting the play or record button you can record a video of your composition to share with others. Once you hit stop, the recording will be saved and ready to share.", preferredStyle: .alert) 
     let okAction = UIAlertAction(title: "OK", style: .default, handler: nil) 
     alert.addAction(okAction) 
     self.present(alert, animated: true, completion: nil) 
    } 
} 

func previewControllerDidFinish(_ previewController: RPPreviewViewController) { 
    let audioSession = AVAudioSession.sharedInstance() 
    try! audioSession.setCategory(AVAudioSessionCategoryPlayback) 
    dismiss(animated: true) 
} 

回答

1

不知道这是任何帮助,但只是发现问题与我们的,在这里我们使用OalPlayback的声音效果。在显示预览控制器之前,我现在释放Oal对象,在解除预览之后,我创建一个新对象。

+0

我的解决方案是类似的。我们有一个播放MIDI的“合成器”(Synthesizer)对象,然后将其删除,然后制作一个新的工具。不幸的是,并没有真正解释发生了什么。 – CodyMace

+0

这是一个非常时髦的控制器。我已经停止了断点,甚至在应用程序显示并且所有控件继续工作时甚至崩溃了。 – Jer

+0

哈哈哇,这是搞砸了。 – CodyMace

0

我使用ObjectAL并发现这个问题。我能够通过使用这个命令来解决它:

OALAudioSession.sharedInstance().forceEndInterruption() 

似乎replayKit没有结束中断。