mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 08:20:59 +00:00
Fix audio session
This commit is contained in:
parent
2c7ca2ca81
commit
c4c86e1434
2 changed files with 10 additions and 11 deletions
|
@ -83,7 +83,8 @@ class AppDelegate: NSObject, UIApplicationDelegate {
|
|||
func application(_: UIApplication,
|
||||
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool
|
||||
{
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient)
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -78,19 +78,9 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
||||
isCompact: isCompact)
|
||||
viewModel.mute(preferences.muteVideo)
|
||||
|
||||
DispatchQueue.global().async {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
viewModel.pause()
|
||||
|
||||
DispatchQueue.global().async {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
if !preferences.autoPlayVideo && !viewModel.isPlaying {
|
||||
|
@ -111,6 +101,11 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
}
|
||||
}
|
||||
.onAppear {
|
||||
DispatchQueue.global().async {
|
||||
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
||||
try? AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
if isCompact || !preferences.autoPlayVideo {
|
||||
viewModel.play()
|
||||
}
|
||||
|
@ -121,6 +116,9 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
viewModel.pause()
|
||||
}
|
||||
viewModel.mute(preferences.muteVideo)
|
||||
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
}
|
||||
.cornerRadius(4)
|
||||
|
|
Loading…
Reference in a new issue