Hide video controls in gallery if loading fails

Closes #546
This commit is contained in:
Shadowfacts 2024-11-25 21:09:32 -05:00
parent dc01804359
commit b700e17d7e
1 changed files with 8 additions and 2 deletions

View File

@ -20,6 +20,7 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
private var statusObservation: NSKeyValueObservation?
private var rateObservation: NSKeyValueObservation?
private var hideControlsWorkItem: DispatchWorkItem?
private var isShowingError = false
public init(url: URL, caption: String?) {
self.url = url
@ -90,12 +91,15 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
self.container?.setGalleryContentLoading(false)
self.showErrorView(error)
self.statusObservation = nil
self.overlayVC.setVisible(false)
}
}
})
}
private func showErrorView(_ error: any Error) {
isShowingError = true
let image = UIImageView(image: UIImage(systemName: "exclamationmark.triangle.fill")!)
image.tintColor = .secondaryLabel
image.contentMode = .scaleAspectFit
@ -158,7 +162,7 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
}
public var presentationAnimation: GalleryContentPresentationAnimation {
.fromSourceViewWithoutSnapshot
isShowingError ? .fade : .fromSourceViewWithoutSnapshot
}
private lazy var overlayVC = VideoOverlayViewController(player: player)
@ -169,7 +173,9 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
public private(set) lazy var bottomControlsAccessoryViewController: UIViewController? = VideoControlsViewController(player: player)
public func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) {
overlayVC.setVisible(visible)
if !isShowingError {
overlayVC.setVisible(visible)
}
if !visible {
hideControlsWorkItem?.cancel()