2017-01-10 58 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沒有結束中斷。