5 Star 82 Fork 15

RTE-Dev / RedPlayer

forked from CY. / RedPlayer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
RedPreload_SDK.md 2.98 KB
一键复制 编辑 原始数据 按行查看 历史
hongdaLL 提交于 2023-11-14 10:49 . Open RedPlayer v1.0 modifies

RedPreload SDK

The RedPreload SDK is a powerful tool for preloading videos and improving the user experience. It provides a range of features, including message callbacks, initialization with cache path and maximum size, and more. This guide will walk you through the steps to use the RedPreload SDK.

Key Features

  • Provides message callbacks for various events
  • Supports initialization with cache path and maximum size
  • Offers methods to open URLs and JSON with parameters and user data
  • Supports stopping preload and deleting cache

Header Files References:

▶️ Getting Started

Set Preload Message Callback

To set the preload message callback, use the following method:

+ (void)setPreLoadMsgCallback:(RedPreLoadCallback)callback;

Initialize Preload

To initialize preload with cache path and maximum size, use the following method:

+ (void)initPreLoad:(NSString *)cachePath maxSize:(uint32_t)maxSize;

To initialize preload with cache path, maximum size(byte), and maximum directory capacity, use the following method:

+ (void)initPreLoad:(NSString *)cachePath maxSize:(uint32_t)maxSize maxdircapacity:(int64_t)maxdircapacity;

Open URLs and JSON

To open URLs with parameters and user data, use the following method:

/// Struct for RedPreloadParam
typedef struct {
    NSString* cachePath; ///< Cache path
    int64_t preloadSize; ///< Preload size bytes
    NSString* referer; ///< Referer
    int dnsTimeout; ///< DNS timeout
    bool useHttps; ///< Use HTTPS or not
    NSString* userAgent; ///< User agent
    NSString* header; ///< Header
    int64_t cache_max_dir_capacity; ///< Maximum directory capacity for cache
    uint32_t cache_max_entries; ///< Maximum entries for cache
} RedPreloadParam;

+ (void)open:(NSURL *)url param:(RedPreloadParam)param userData:(void* _Nullable)userData;

To open JSON with parameters and user data, use the following method:

+ (void)openJson:(NSString *)jsonStr param:(RedPreloadParam)param userData:(void* _Nullable)userData;

Close URLs and JSON

To close URL preload task, use the following method:

+ (void)close:(NSURL *)url;

To close JSON preload task, use the following method:

+ (void)closeJson:(NSString *)jsonStr;

Stop Preload

To stop all preload tasks, use the following method:

+ (void)stop;

Get Cached Size and Files

To get cached size, use the following method:

+ (int64_t)getCachedSize:(NSString *)path uri:(NSString*)uri isFullUrl:(BOOL)isFullUrl;

To get all cached files, use the following method:

+ (NSArray<NSString *> *)getAllCachedFile:(NSString *)path;

Delete Cache

To delete cache, use the following method:

+ (int)deleteCache:(NSString *)path uri:(NSString *)uri isFullUrl:(BOOL)isFullUrl;
1
https://gitee.com/rte-dev/RedPlayer.git
git@gitee.com:rte-dev/RedPlayer.git
rte-dev
RedPlayer
RedPlayer
main

搜索帮助