Correctly setting the audio session category before playing attachments

pull/951/head
Morgan Pretty 1 year ago
parent 14a3a3e018
commit 7ef087a16b

@ -963,6 +963,9 @@ extension ConversationVC:
FileManager.default.fileExists(atPath: originalFilePath)
else { return SNLog("Missing video file") }
/// When playing media we need to change the AVAudioSession to 'playback' mode so the device "silent mode"
/// doesn't prevent video audio from playing
try? AVAudioSession.sharedInstance().setCategory(.playback)
let viewController: AVPlayerViewController = AVPlayerViewController()
viewController.player = AVPlayer(url: URL(fileURLWithPath: originalFilePath))
self.navigationController?.present(viewController, animated: true)
@ -1006,7 +1009,9 @@ extension ConversationVC:
let originalFilePath: String = attachment.originalFilePath
else { return }
// Use the native player to play audio files
/// When playing media we need to change the AVAudioSession to 'playback' mode so the device "silent mode"
/// doesn't prevent video audio from playing
try? AVAudioSession.sharedInstance().setCategory(.playback)
let viewController: AVPlayerViewController = AVPlayerViewController()
viewController.player = AVPlayer(url: URL(fileURLWithPath: originalFilePath))
self.navigationController?.present(viewController, animated: true)

Loading…
Cancel
Save