Fix video playback in iOS < 17.5

(cherry picked from commit 5c5236ce4cebc3ee47218f69f8be422d7c04a5d9)
This commit is contained in:
Isaac 2024-12-06 22:14:00 +08:00
parent 67ed6f9b8e
commit af8276cf2d
2 changed files with 9 additions and 3 deletions

View File

@ -342,7 +342,7 @@ private final class MediaPlayerContext {
let _ = self.playerStatusValue.swap(status)
}
let frameSource = FFMpegMediaFrameSource(queue: self.queue, postbox: self.postbox, userLocation: self.userLocation, userContentType: self.userContentType, resourceReference: self.resourceReference, tempFilePath: self.tempFilePath, limitedFileRange: self.limitedFileRange, streamable: self.streamable.enabled, isSeekable: self.streamable.isSeekable, video: self.video, preferSoftwareDecoding: self.preferSoftwareDecoding, fetchAutomatically: self.fetchAutomatically, stallDuration: self.streamable.parameters.0, lowWaterDuration: self.streamable.parameters.1, highWaterDuration: self.streamable.parameters.2, storeAfterDownload: self.storeAfterDownload)
let frameSource = FFMpegMediaFrameSource(queue: self.queue, postbox: self.postbox, userLocation: self.userLocation, userContentType: self.userContentType, resourceReference: self.resourceReference, tempFilePath: self.tempFilePath, limitedFileRange: self.limitedFileRange, streamable: self.streamable.enabled, isSeekable: self.streamable.isSeekable, video: self.video, preferSoftwareDecoding: self.preferSoftwareDecoding, fetchAutomatically: self.fetchAutomatically, stallDuration: self.streamable.parameters.0, lowWaterDuration: self.streamable.parameters.1, highWaterDuration: self.streamable.parameters.2, storeAfterDownload: self.storeAfterDownload, isAudioVideoMessage: self.isAudioVideoMessage)
let disposable = MetaDisposable()
let updatedSeekState: MediaPlayerSeekState?
if let loadedDuration = loadedDuration {

View File

@ -221,7 +221,10 @@ public final class MediaPlayerNode: ASDisplayNode {
videoLayer.enqueue(frame.sampleBuffer)
if #available(iOS 17.4, *) {
} else {
strongSelf.hasSentFramesToDisplay?()
if !strongSelf.didNotifyVideoLayerReadyForDisplay {
strongSelf.didNotifyVideoLayerReadyForDisplay = true
strongSelf.hasSentFramesToDisplay?()
}
}
}
}
@ -257,7 +260,10 @@ public final class MediaPlayerNode: ASDisplayNode {
return
}
videoLayer.enqueue(frame.sampleBuffer)
//strongSelf.hasSentFramesToDisplay?()
if !strongSelf.didNotifyVideoLayerReadyForDisplay {
strongSelf.didNotifyVideoLayerReadyForDisplay = true
strongSelf.hasSentFramesToDisplay?()
}
}
Queue.mainQueue().async {