mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-09-24 12:40:01 +00:00
Don't autoplay in compact mode
This commit is contained in:
parent
5ca5dfbd24
commit
d378341914
1 changed files with 5 additions and 4 deletions
|
@ -16,10 +16,10 @@ import SwiftUI
|
||||||
self.forceAutoPlay = forceAutoPlay
|
self.forceAutoPlay = forceAutoPlay
|
||||||
}
|
}
|
||||||
|
|
||||||
func preparePlayer(autoPlay: Bool) {
|
func preparePlayer(autoPlay: Bool, isCompact: Bool) {
|
||||||
player = .init(url: url)
|
player = .init(url: url)
|
||||||
player?.audiovisualBackgroundPlaybackPolicy = .pauses
|
player?.audiovisualBackgroundPlaybackPolicy = .pauses
|
||||||
if autoPlay || forceAutoPlay {
|
if (autoPlay || forceAutoPlay) && !isCompact {
|
||||||
player?.play()
|
player?.play()
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,7 +72,8 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
videoView
|
videoView
|
||||||
.onAppear {
|
.onAppear {
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.playback)
|
try? AVAudioSession.sharedInstance().setCategory(.playback)
|
||||||
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo)
|
viewModel.preparePlayer(autoPlay: isFullScreen ? true : preferences.autoPlayVideo,
|
||||||
|
isCompact: isCompact)
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
try? AVAudioSession.sharedInstance().setCategory(.ambient)
|
try? AVAudioSession.sharedInstance().setCategory(.ambient)
|
||||||
|
@ -99,7 +100,7 @@ public struct MediaUIAttachmentVideoView: View {
|
||||||
case .background, .inactive:
|
case .background, .inactive:
|
||||||
viewModel.pause()
|
viewModel.pause()
|
||||||
case .active:
|
case .active:
|
||||||
if preferences.autoPlayVideo || viewModel.forceAutoPlay || isFullScreen {
|
if (preferences.autoPlayVideo || viewModel.forceAutoPlay || isFullScreen) && !isCompact {
|
||||||
viewModel.play()
|
viewModel.play()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue