mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 17:51:01 +00:00
More video tweaks
This commit is contained in:
parent
cd63c9ddff
commit
c09f9727f1
1 changed files with 17 additions and 6 deletions
|
@ -53,6 +53,11 @@ import SwiftUI
|
|||
player?.play()
|
||||
}
|
||||
|
||||
func resume() {
|
||||
isPlaying = true
|
||||
player?.play()
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: nil)
|
||||
}
|
||||
|
@ -106,21 +111,27 @@ public struct MediaUIAttachmentVideoView: View {
|
|||
try? AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
viewModel.mute(false)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
if isCompact || !preferences.autoPlayVideo {
|
||||
viewModel.play()
|
||||
} else {
|
||||
viewModel.resume()
|
||||
}
|
||||
}
|
||||
viewModel.mute(false)
|
||||
}
|
||||
.onDisappear {
|
||||
if isCompact || !preferences.autoPlayVideo {
|
||||
viewModel.pause()
|
||||
}
|
||||
viewModel.mute(preferences.muteVideo)
|
||||
DispatchQueue.global().async {
|
||||
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
.cornerRadius(4)
|
||||
.onChange(of: scenePhase) { _, newValue in
|
||||
switch newValue {
|
||||
|
|
Loading…
Reference in a new issue