Separate 'isVideo' from 'isVideoReadyToPlay'

This commit is contained in:
Pete Walters 2026-05-12 11:33:04 -05:00 committed by GitHub
parent 32d0afac3a
commit c75e957b68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 9 deletions

View File

@ -57,7 +57,13 @@ public class ReusableMediaView {
}
var isVideo: Bool {
mediaViewAdapter is MediaViewAdapterVideo
if mediaViewAdapter is MediaViewAdapterVideo {
return true
}
if let thumbnail = mediaViewAdapter as? MediaViewAdapterBackupThumbnail {
return thumbnail.isVideo
}
return false
}
// MARK: - LoadState
@ -407,6 +413,10 @@ class MediaViewAdapterBackupThumbnail: MediaViewAdapter {
imageView
}
var isVideo: Bool {
attachmentBackupThumbnail.attachment.contentType.isVideo
}
var isLoaded: Bool {
imageView.image != nil
}

View File

@ -88,16 +88,21 @@ struct MediaGalleryItem: Equatable, Hashable, MediaGallerySectionItem {
var isVideo: Bool {
switch referencedAttachment.attachment.contentType {
case .video:
// For now, if the video isn't a stream, don't treat it as a video.
if referencedAttachment.asReferencedStream == nil {
return false
}
return renderingFlag != .shouldLoop
return true
case .file, .image, .audio:
return false
}
}
var isVideoReadyToPlay: Bool {
switch referencedAttachment.attachment.contentType {
case .video where referencedAttachment.asReferencedStream != nil:
return renderingFlag != .shouldLoop
case .file, .image, .audio, .video:
return false
}
}
var isAnimated: Bool {
switch referencedAttachment.attachment.contentType {
case .video:

View File

@ -59,8 +59,7 @@ class MediaItemViewController: OWSViewController, VideoPlaybackStatusProvider {
}
private func configureVideoPlaybackControls() {
guard videoPlayerView != nil else {
owsFailBeta("No videoPlayer")
guard isVideo else {
return
}

View File

@ -296,7 +296,7 @@ class MediaPageViewController: UIPageViewController {
}
let mediaPage = buildGalleryPage(galleryItem: item)
mediaPage.shouldAutoPlayVideo = true
mediaPage.shouldAutoPlayVideo = item.isVideoReadyToPlay
setViewControllers([mediaPage], direction: direction, animated: animated) { _ in
self.didTransitionToNewPage(animated: animated, direction: direction)
}