From 13f442485d2844bf8476d0cff923e587a9d63277 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 6 Dec 2024 22:15:15 +0800 Subject: [PATCH] Add video cache --- .../Sources/HLSVideoJSNativeContentNode.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/submodules/TelegramUniversalVideoContent/Sources/HLSVideoJSNativeContentNode.swift b/submodules/TelegramUniversalVideoContent/Sources/HLSVideoJSNativeContentNode.swift index 52c451fc39..8e446c3849 100644 --- a/submodules/TelegramUniversalVideoContent/Sources/HLSVideoJSNativeContentNode.swift +++ b/submodules/TelegramUniversalVideoContent/Sources/HLSVideoJSNativeContentNode.swift @@ -296,11 +296,9 @@ final class HLSJSServerSource: SharedHLSServer.Source { let fetchTime = CFAbsoluteTimeGetCurrent() - startTime print("Fetching \(quality)p part took \(fetchTime * 1000.0) ms") #endif - if let preloadRange, Int(preloadRange.lowerBound) <= range.upperBound && Int(preloadRange.upperBound) >= range.lowerBound { - if let data = try? Data(contentsOf: URL(fileURLWithPath: partialFile.path), options: .alwaysMapped) { - let subData = data.subdata(in: Int(result.offset) ..< Int(result.offset + result.size)) - postbox.mediaBox.storeResourceData(file.media.resource.id, range: Int64(range.lowerBound) ..< Int64(range.upperBound), data: subData) - } + if let data = try? Data(contentsOf: URL(fileURLWithPath: partialFile.path), options: .alwaysMapped) { + let subData = data.subdata(in: Int(result.offset) ..< Int(result.offset + result.size)) + postbox.mediaBox.storeResourceData(file.media.resource.id, range: Int64(range.lowerBound) ..< Int64(range.upperBound), data: subData) } subscriber.putNext((partialFile, Int(result.offset) ..< Int(result.offset + result.size), Int(size))) subscriber.putCompletion()