mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Fix auto play video settings close #636
This commit is contained in:
parent
71f6cfd52a
commit
1bf36670e2
1 changed files with 9 additions and 3 deletions
|
@ -16,12 +16,16 @@ class VideoPlayerViewModel: ObservableObject {
|
|||
player?.audiovisualBackgroundPlaybackPolicy = .pauses
|
||||
if autoPlay {
|
||||
player?.play()
|
||||
} else {
|
||||
player?.pause()
|
||||
}
|
||||
guard let player else { return }
|
||||
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime,
|
||||
object: player.currentItem, queue: .main) { [weak self] _ in
|
||||
self?.player?.seek(to: CMTime.zero)
|
||||
self?.player?.play()
|
||||
if autoPlay {
|
||||
self?.player?.seek(to: CMTime.zero)
|
||||
self?.player?.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +59,9 @@ struct VideoPlayerView: View {
|
|||
case .background, .inactive:
|
||||
viewModel.pause()
|
||||
case .active:
|
||||
viewModel.play()
|
||||
if preferences.autoPlayVideo {
|
||||
viewModel.play()
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue