forked from shadowfacts/Tusker
parent
dc01804359
commit
b35c69da96
|
@ -20,12 +20,13 @@ 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
|
||||
self.caption = caption
|
||||
|
||||
let asset = AVAsset(url: url)
|
||||
let asset = AVAsset(url: URL(string: "http://example.com/test.mp4")!)
|
||||
self.item = Self.createItem(asset: asset)
|
||||
self.player = AVPlayer(playerItem: item)
|
||||
|
||||
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue