ZPlayerCacher is a lightweight implementation of the AVAssetResourceLoaderDelegate protocol that enables AVPlayerItem to support caching streaming files.
Please note that while this project serves as a demonstration of AVFoundation AVAssetResourceLoaderDelegate and the use of Combine to manage data flow, the code may not be written to the highest standard of cleanliness. If you have any suggestions for improving the code, please feel free to create an issue or pull request on the repository.
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/ZhgChgLi/ZPlayerCacher.git
- Select "Up to Next Major" with "1.0.0"
or
...
dependencies: [
.package(url: "https://github.com/ZhgChgLi/ZPlayerCacher.git", from: "1.0.0"),
]
...
.target(
...
dependencies: [
"ZPlayerCacher",
],
...
)
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'ZPlayerCacher', '~> 1.0.0'
end
let cacher: Cacher = // your implementation of Local Cache policy (Cacher Protocol), ref: PINCacher.md
let logger = DefaultPlayerCacherLogger() // could use default
let factory = CacheableAVURLAssetFactory(cacher: cacher, logger: logger).makeCacheableAVURLAssetIfSupported(url: url)
let playerItem = AVPlayerItem(asset: asset) // than playerItem will support caching
- Due to limitations in the Apple iOS system, currently unsupported video formats such as HLS file format(.ts) are not supported by ZPlayerCacher.
Pinkoi.com is Asia's leading online marketplace for original design goods, digital creations, and workshop experiences.
- ZMarkupParser is a pure-Swift library that helps you to convert HTML strings to NSAttributedString with customized style and tags.
- ZPlayerCacher is a lightweight implementation of the AVAssetResourceLoaderDelegate protocol that enables AVPlayerItem to support caching streaming files.
- ZNSTextAttachment enables NSTextAttachment to download images from remote URLs, support both UITextView and UILabel.
- ZReviewTender is a tool for fetching app reviews from the App Store and Google Play Console and integrating them into your workflow.
- ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format.
If you find this library helpful, please consider starring the repo or recommending it to your friends.
Feel free to open an issue or submit a fix/contribution via pull request. :)