簡體   English   中英

RPPreviewViewController 在播放后禁用音頻

[英]RPPreviewViewController disables audio after playback

我在我的應用程序中使用 replaykit,在用戶完成錄制后,我提供了一個按鈕來“共享”視頻。 我展示了RPPreviewViewController ,如果我在視頻中點擊播放,當我回到應用程序時,音頻不起作用。 只有當我回到以前的viewController並返回到帶有記錄的viewController ,它才會再次工作。

我的應用程序是一個音樂創作應用程序,所以音頻非常重要。 我什至嘗試在播放視圖關閉后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)
}

不確定這是否有幫助,但剛剛發現我們的問題,我們使用 OalPlayback 進行音效。 在顯示預覽控制器之前,我現在釋放 Oal 對象,並在取消預覽后創建一個新對象。

我使用 ObjectAL 也發現了這個問題。 我能夠使用以下命令解決它:

OALAudioSession.sharedInstance().forceEndInterruption()

似乎 replayKit 沒有結束中斷。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM