tencent cloud

最終更新日:2025-05-30 14:55:49
TXVodDownloadManager
最終更新日: 2025-05-30 14:55:49

TXDownloadError

Download Error Code.
Value
Parameter Name
Description
0
TXDownloadSuccess
Download success.
-5001
TXDownloadAuthFaild
File ID authentication failure.
-5003
TXDownloadNoFile
No file with this resolution.
-5004
TXDownloadFormatError
Unsupported format.
-5005
TXDownloadDisconnet
Network disconnection.
-5006
TXDownloadHlsKeyError
Failed to retrieve the HLS decryption key.
-5007
TXDownloadPathError
Download directory access failure.
-5008
TXDownload403Forbidden
Authentication information not approved, such as signature expiration or invalid request.

TXVodDownloadManager API Introduction

on-demand video player download API class
Video download supports downloading MP4 and HLS videos, corresponds to nested HLS videos, requires specifying preferred resolution (preferredResolution)

API Overview

API
Description
Retrieve the TXVodDownloadManager instance object in singleton mode.
Set the root directory for downloading files. If it does not exist, it will be automatically created.
Start the download using the URL method.
Start the download using the fileId method.
Start the download using the URL method, and specify the preferred clarity and account name.
Start the download using the Drm method.
Stop download, stopped successfully when [TXVodDownloadDelegate onDownloadStop:] callback is triggered.
Delete download information.
Delete files generated during download.
Retrieve download list information for all users, time-consuming API, do not call on the main thread.
Retrieve download information.
Retrieve download information.
Encrypt.
headers
Set the HTTP request header for downloading.
delegate
Set the download callback proxy object. It must be configured before downloading.
Set whether private encryption mode is supported (set to NO for system player, YES for custom player). By default, it is set to YES.

API Detail

shareInstance

Retrieve the TXVodDownloadManager instance object in singleton mode.
+ (TXVodDownloadManager *)shareInstance;

setDownloadPath:

Set the root directory for downloading files. The download directory set here takes precedence over the one set via [TXPlayerGlobalSetting setCacheFolderPath:].
- (void)setDownloadPath:(NSString *)path;

startDownload:

Start the download using the Tencent Cloud Video fileId method.
- (TXVodDownloadMediaInfo *)startDownload:(TXVodDownloadDataSource *)source;
Parameter Description
Parameter Name
Type
Description
source
Download a resource object.

startDownload:url:

Start the download using the URL method.
- (TXVodDownloadMediaInfo *)startDownload:(NSString *)username url:(NSString *)url;
Parameter Description
Parameter Name
Type
Description
url
NSString
Download address, required.
username
NSString
Account name, optional parameter, defaults to "default" if not provided.
Return Value
Video information and download status, see TXVodDownloadMediaInfo for details.

startDownloadUrl:resolution:userName:

Start the download using the URL method.
- (TXVodDownloadMediaInfo *)startDownloadUrl:(NSString *)url resolution:(long)resolution userName:(NSString *)username;
Parameter Description
Parameter Name
Type
Description
url
NSString
Download address, required.
resolution
long
Preference for clarity, multiple resolutions url is a required parameter, with the value being preference clarity width × height (e.g., 720p input 921600 = 1280 × 720), single clarity input -1.
username
NSString
Account name, optional parameter, defaults to "default" if not provided.
Return Value
Video information and download status, see TXVodDownloadMediaInfo for details.

startDownloadDrm:resolution:userName:

Download a DRM video.
- (TXVodDownloadMediaInfo *)startDownloadDrm:(TXPlayerDrmBuilder *)drmBuilder resolution:(long)resolution userName:(NSString *)username;
Parameter Description
Parameter Name
Type
Description
drmBuilder
TXPlayerDrmBuilder
Download DRM object, refer to TXPlayerDrmBuilder.
resolution
long
Preference clarity, multiple resolutions URL is a required parameter, with the value being preference clarity width * height (e.g., 720p input 921600 = 1280 * 720), single clarity input -1.
username
NSString
Account name, optional parameter, defaults to "default" if not provided.
Return Value
Video information and download status, see TXVodDownloadMediaInfo for details.

stopDownload:

Stop download, stopped successfully when -[id<TXVodDownloadDelegate> onDownloadStop:] callback is triggered.
- (void)stopDownload:(TXVodDownloadMediaInfo *)media;
Parameter Description
Parameter Name
Type
Description
downloadMediaInfo
Download video information.

deleteDownloadMediaInfo:

Delete download information.
- (BOOL)deleteDownloadMediaInfo:(TXVodDownloadMediaInfo *)downloadMediaInfo;
Parameter Description
Parameter Name
Type
Description
downloadMediaInfo
Download video information.
Return Value
Whether the deletion is successful. YES: Successfully deleted; NO: Deletion failed. Files being downloaded cannot be deleted.

getDownloadMediaInfoList

Retrieve download list information for all users.
- (NSArray<TXVodDownloadMediaInfo *> *)getDownloadMediaInfoList;
Return Value
Video download information list: NSArray<TXVodDownloadMediaInfo>.

getDownloadMediaInfo:fileId:qualityId:userName:

Retrieve download information.
Call this API to ensure that a download task has been created earlier via startDownload:, startDownload:url:, or startDownloadDrm:resolution:userName:.
- (TXVodDownloadMediaInfo *)getDownloadMediaInfo:(int)appId fileId:(NSString *)fileId qualityId:(int)qualityId userName:(NSString *)userName;
Parameter Description
Parameter Name
Type
Description
appId
int
Tencent Cloud Video on Demand (VOD) application appId.
fileId
NSString
Tencent Cloud Video on Demand (VOD) video fileId.
qualityId
int
Video quality Id, refer to the constant TXVodQuality.
userName
NSString
Account name must be consistent with the account name passed in during download. If not passed in during download, pass in the empty character "".
Return Value
Video download information TXVodDownloadMediaInfo.

getDownloadMediaInfo:resolution:userName:

Retrieve download information.
- (TXVodDownloadMediaInfo *)getDownloadMediaInfo:(NSString *)url resolution:(long)preferredResolution userName:(NSString *)userName;
Parameter Description
Parameter Name
Type
Description
url
NSString
Download address, required parameter, otherwise download fails.
preferredResolution
long
Download preferred clarity, multiple resolutions URL is a required parameter, with the value being preferred clarity width × height (e.g., 720p input 921600 = 1280 × 720), single clarity input -1.
userName
userName
Account name, optional parameter, defaults to "default" if not provided.
Return Value
Video download information TXVodDownloadMediaInfo.

encryptHexStringHls:

Encrypt.

+ (NSString *)encryptHexStringHls:(NSString *)originHexStr
Parameter Name
Type
Description
originHexStr
NSString
Initial hexadecimal string.
Return Value
Encrypted string: NSString

headers

Set the http request header.

@property(nonatomic, strong) NSDictionary *headers;
Parameter Name
Type
Description
headers
NSDictionary
http request header.

delegate

Set the download task callback object.

@property(nonatomic, weak) id<TXVodDownloadDelegate> delegate;
Parameter Name
Type
Description
delegate
Download task callback object.

supportPrivateEncryptMode

Set whether private encryption mode is supported (set to NO for system player, YES for custom player). Default is YES.

@property(nonatomic, assign) BOOL supportPrivateEncryptMode;
Parameter Name
Type
Description
supportPrivateEncryptMode
BOOL
Whether private encryption mode is supported.

この記事はお役に立ちましたか?
営業担当者に お問い合わせ いただくか チケットを提出 してサポートを求めることができます。
はい
いいえ

フィードバック