mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +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,
|
func application(_: UIApplication,
|
||||||
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool
|
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)
|
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,19 +78,9 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
||||||
isCompact: isCompact)
|
isCompact: isCompact)
|
||||||
viewModel.mute(preferences.muteVideo)
|
viewModel.mute(preferences.muteVideo)
|
||||||
|
|
||||||
DispatchQueue.global().async {
|
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
|
|
||||||
try? AVAudioSession.sharedInstance().setActive(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
viewModel.pause()
|
viewModel.pause()
|
||||||
|
|
||||||
DispatchQueue.global().async {
|
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
|
||||||
try? AVAudioSession.sharedInstance().setActive(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if !preferences.autoPlayVideo && !viewModel.isPlaying {
|
if !preferences.autoPlayVideo && !viewModel.isPlaying {
|
||||||
|
@ -111,6 +101,11 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.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 {
|
if isCompact || !preferences.autoPlayVideo {
|
||||||
viewModel.play()
|
viewModel.play()
|
||||||
}
|
}
|
||||||
|
@ -121,6 +116,9 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
viewModel.pause()
|
viewModel.pause()
|
||||||
}
|
}
|
||||||
viewModel.mute(preferences.muteVideo)
|
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)
|
.cornerRadius(4)
|
||||||
|
|
Loading…
Reference in a new issue