Pause scrolled video

This commit is contained in:
Lumaa 2024-01-06 02:51:28 +01:00
parent 7c059fa652
commit 2ff6d93b69

View File

@ -77,6 +77,10 @@ struct PostAttachment: View {
} }
} }
} }
.onDisappear() {
guard player != nil else { return }
player?.pause()
}
} else if attachment.supportedType == .video { } else if attachment.supportedType == .video {
ZStack { ZStack {
@ -101,6 +105,10 @@ struct PostAttachment: View {
player?.play() player?.play()
} }
} }
.onDisappear() {
guard player != nil else { return }
player?.pause()
}
} }
} }
.frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height) .frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height)
@ -144,7 +152,6 @@ class NoControlsAVPlayerViewController: AVPlayerViewController {
} }
} }
// Create a UIViewRepresentable for the customized AVPlayerViewController
struct NoControlsPlayerViewController: UIViewControllerRepresentable { struct NoControlsPlayerViewController: UIViewControllerRepresentable {
let player: AVPlayer let player: AVPlayer