mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +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()
|
player?.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resume() {
|
||||||
|
isPlaying = true
|
||||||
|
player?.play()
|
||||||
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: nil)
|
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().setCategory(.playback, options: .duckOthers)
|
||||||
try? AVAudioSession.sharedInstance().setActive(true)
|
try? AVAudioSession.sharedInstance().setActive(true)
|
||||||
}
|
}
|
||||||
|
viewModel.mute(false)
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||||
if isCompact || !preferences.autoPlayVideo {
|
if isCompact || !preferences.autoPlayVideo {
|
||||||
viewModel.play()
|
viewModel.play()
|
||||||
|
} else {
|
||||||
|
viewModel.resume()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
viewModel.mute(false)
|
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
if isCompact || !preferences.autoPlayVideo {
|
if isCompact || !preferences.autoPlayVideo {
|
||||||
viewModel.pause()
|
viewModel.pause()
|
||||||
}
|
}
|
||||||
viewModel.mute(preferences.muteVideo)
|
viewModel.mute(preferences.muteVideo)
|
||||||
|
DispatchQueue.global().async {
|
||||||
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||||
try? AVAudioSession.sharedInstance().setActive(true)
|
try? AVAudioSession.sharedInstance().setActive(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.cornerRadius(4)
|
.cornerRadius(4)
|
||||||
.onChange(of: scenePhase) { _, newValue in
|
.onChange(of: scenePhase) { _, newValue in
|
||||||
switch newValue {
|
switch newValue {
|
||||||
|
|
Loading…
Reference in a new issue