parent
dc01804359
commit
b35c69da96
|
@ -20,12 +20,13 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
|
||||||
private var statusObservation: NSKeyValueObservation?
|
private var statusObservation: NSKeyValueObservation?
|
||||||
private var rateObservation: NSKeyValueObservation?
|
private var rateObservation: NSKeyValueObservation?
|
||||||
private var hideControlsWorkItem: DispatchWorkItem?
|
private var hideControlsWorkItem: DispatchWorkItem?
|
||||||
|
private var isShowingError = false
|
||||||
|
|
||||||
public init(url: URL, caption: String?) {
|
public init(url: URL, caption: String?) {
|
||||||
self.url = url
|
self.url = url
|
||||||
self.caption = caption
|
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.item = Self.createItem(asset: asset)
|
||||||
self.player = AVPlayer(playerItem: item)
|
self.player = AVPlayer(playerItem: item)
|
||||||
|
|
||||||
|
@ -90,12 +91,15 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
|
||||||
self.container?.setGalleryContentLoading(false)
|
self.container?.setGalleryContentLoading(false)
|
||||||
self.showErrorView(error)
|
self.showErrorView(error)
|
||||||
self.statusObservation = nil
|
self.statusObservation = nil
|
||||||
|
self.overlayVC.setVisible(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showErrorView(_ error: any Error) {
|
private func showErrorView(_ error: any Error) {
|
||||||
|
isShowingError = true
|
||||||
|
|
||||||
let image = UIImageView(image: UIImage(systemName: "exclamationmark.triangle.fill")!)
|
let image = UIImageView(image: UIImage(systemName: "exclamationmark.triangle.fill")!)
|
||||||
image.tintColor = .secondaryLabel
|
image.tintColor = .secondaryLabel
|
||||||
image.contentMode = .scaleAspectFit
|
image.contentMode = .scaleAspectFit
|
||||||
|
@ -158,7 +162,7 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi
|
||||||
}
|
}
|
||||||
|
|
||||||
public var presentationAnimation: GalleryContentPresentationAnimation {
|
public var presentationAnimation: GalleryContentPresentationAnimation {
|
||||||
.fromSourceViewWithoutSnapshot
|
isShowingError ? .fade : .fromSourceViewWithoutSnapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
private lazy var overlayVC = VideoOverlayViewController(player: player)
|
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 private(set) lazy var bottomControlsAccessoryViewController: UIViewController? = VideoControlsViewController(player: player)
|
||||||
|
|
||||||
public func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) {
|
public func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) {
|
||||||
overlayVC.setVisible(visible)
|
if !isShowingError {
|
||||||
|
overlayVC.setVisible(visible)
|
||||||
|
}
|
||||||
|
|
||||||
if !visible {
|
if !visible {
|
||||||
hideControlsWorkItem?.cancel()
|
hideControlsWorkItem?.cancel()
|
||||||
|
|
Loading…
Reference in New Issue