typedef NS_ENUM( NSInteger, TTVideoEngineFinishReason )
播放结束原因。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineFinishReasonUserExited | 0 | 用户主动退出播放。 |
| TTVideoEngineFinishReasonRelease | 1 | 播放器被释放。 |
| TTVideoEngineFinishReasondReleaseAsync | 2 | 播放器被异步释放。 |
| TTVideoEngineFinishReasonPlaybackEnded | 3 | 播放器正常播放完成。 |
| TTVideoEngineFinishReasonPlaybackError | 4 | 播放器发生错误。 |
| TTVideoEngineFinishReasonStatusExcp | 5 | 播放器发生异常。 |
| TTVideoEngineFinishReasonReset | 6 | 播放器重置。 |
@interface TTVideoEnginePreloaderURLItem (PreloadItem)
DirectUrl 视频源预加载 item。
| 返回 | 名称 |
|---|---|
| nullable instancetype | urlItemWithVideoSource:preloadSize: |
+ (nullable instancetype)urlItemWithVideoSource:(id<TTVideoEngineMediaSource>)source preloadSize:(NSInteger)preloadSize;
构造一个 DirectUrl 播放源预加载 Item 实例。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| source | id<TTVideoEngineMediaSource> | DirectUrl 播放源信息 TTVideoEngineMediaSource 。 |
| preloadSize | NSInteger | 预加载数据大小,单位:byte。例如 800 * 1024 代表预加载 800k 数据。 |
返回值
返回 DirectUrl 播放源预加载 Item 实例。
typedef NS_ENUM( NSInteger, TTVideoEngineStreamType )
视频流类型。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineVideoStream | 0 | 视频流。 |
| TTVideoEngineAudioStream | 1 | 音频流。 |
| 返回 | 名称 |
|---|---|
| void | TTVideoURLRefreshCompleteBlock |
| void | TTVideoURLRefreshErrorBlock |
| void | TTVideoURLRefreshCancelBlock |
typedef void(^TTVideoURLRefreshCompleteBlock)(NSString *newUrl, NSString *expireTimeInMS);
过期 URL 刷新完成 block。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| newUrl | NSString* | 新 URL。 |
| expireTimeInMS | NSString* | 新 URL 的过期时间。精度为毫秒的 Unix 时间戳。 |
typedef void(^TTVideoURLRefreshErrorBlock)(NSError *error);
过期 URL 刷新失败 block。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| error | NSError* | 失败原因。 |
typedef void(^TTVideoURLRefreshCancelBlock)(void);
过期 URL 取消刷新 block。
typedef NS_ENUM( NSUInteger, TTVideoEngineState )
播放器状态。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineStateUnknown | 0 | 初始状态。 |
| TTVideoEngineStateFetchingInfo | 1 | 使用 Vid 模式播放,正在获取播放信息。 |
| TTVideoEngineStateParsingDNS | 2 | 播放器正在进行 DNS 解析。 |
| TTVideoEngineStatePlayerRunning | 3 | 播放器正常播放中。 |
| TTVideoEngineStateError | 4 | 播放器运行发生错误。 |
typedef NS_ENUM( NSUInteger, TTVideoEngineLoadState )
播放器加载状态。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineLoadStateUnknown | 0 | 播放器加载初始状态。 |
| TTVideoEngineLoadStatePlayable | 1 | 播放器加载完成,可开始或恢复播放。 |
| TTVideoEngineLoadStateStalled | 2 | 播放器发生卡顿,正在加载数据。 |
| TTVideoEngineLoadStateError | 3 | 播放器加载数据错误。 |
typedef NS_ENUM( NSInteger, TTVideoEngineStallAction )
导致播放器发生卡顿的具体动作。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineStallActionNone | 0 | 默认值。 |
| TTVideoEngineStallActionSeek | 1 | 用户 seek。 |
| TTVideoEngineStallActionSwitch | 2 | 切换分辨率。 |
@interface TTVideoEngineLoadInfo: NSObject
播放器字幕加载信息。
| 类型 | 名称 |
|---|---|
| NSInteger | firstPts |
| NSInteger | code |
| NSInteger | loadStageCode |
@property (nonatomic, assign) NSInteger firstPts;
首段字幕展示时间戳。
@property (nonatomic, assign) NSInteger code;
字幕加载状态。code 为 0 表示加载成功。
@property (nonatomic, assign) NSInteger loadStageCode;
字幕加载阶段状态码,用于字幕加载失败问题分析
@interface TTVideoEngineSubInfo: NSObject
单段字幕信息。
| 类型 | 名称 |
|---|---|
| NSInteger | pts |
| NSString* | content |
| NSInteger | duration |
@property (nonatomic, assign) NSInteger pts;
该段字幕对应的时间戳,单位为毫秒。
@property (nonatomic, copy) NSString *content;
该段字幕的内容。
@property (nonatomic, assign) NSInteger duration;
该段字幕持续的时间,单位为毫秒。
@interface TTVideoEnginePreloaderSubtitleItem : TTVideoEnginePreloaderItem
Vid 播放源预加载信息。
| 类型 | 名称 |
|---|---|
| NSInteger | subtitleId |
| NSInteger | priorityLevel |
| TTVideoEngineSubDecInfoModel* | subtitleInfoModel |
| 返回 | 名称 |
|---|---|
| instancetype | preloaderSubtitleItem:subtitleId: |
@property (nonatomic, assign) NSInteger subtitleId;
预加载字幕 id。
@property (nonatomic, assign) NSInteger priorityLevel;
预加载优先级,默认为 TTVideoEnginePrloadPriorityDefault。
@property (nonatomic, strong, nonnull) TTVideoEngineSubDecInfoModel *subtitleInfoModel;
字幕源。
+ (instancetype)preloaderSubtitleItem:(TTVideoEngineSubDecInfoModel *)subtitleInfoModel subtitleId:(NSInteger)subtitleId;
创建字幕预加载任务。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| subtitleInfoModel | TTVideoEngineSubDecInfoModel* | 预加载字幕源 |
| subtitleId | NSInteger | 预加载字幕源 |
返回值
返回字幕预加载 Item 实例。
@interface TTVideoEngineLocalServerConfigure : NSObject
数据加载模块配置。数据加载模块(MDL,Media Data Loader)是点播 SDK 内部的关键模块之一,为播放器提供高速、低成本、可靠的数据加载服务。点播 SDK 的预加载、文件缓存、边下边播、网络质量和成本数据监控等功能均依赖于数据模块。点播 SDK 初始化时,会默认启动数据加载模块。
| 类型 | 名称 |
|---|---|
| NSInteger | maxCacheSize |
| NSInteger | preloadParallelNum |
| NSString* | downloadDirectory |
@property(nonatomic, assign) NSInteger maxCacheSize;
设置本地缓存最大数据量,单位为 byte。
@property(nonatomic, assign) NSInteger preloadParallelNum;
设置预加载并发数,默认值为 2。
@property(nonatomic, nullable, copy) NSString *downloadDirectory;
设置下载文件的沙盒存储路径,如果你使用下载功能,该路径必须设置。
@interface TTVideoEngineLocalServerCacheInfo : NSObject
数据加载模块的本地缓存配置信息。
| 类型 | 名称 |
|---|---|
| int64_t | mediaSize |
| NSString* | localFilePath |
@property(nonatomic, assign) int64_t mediaSize;
视频源数据大小,单位:byte。
@property(nonatomic, copy) NSString *localFilePath;
本地缓存路径。
typedef NS_ENUM( NSInteger, TTVideoEnginePlaybackState )
播放状态。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEnginePlaybackStateStopped | 0 | 播放停止。 |
| TTVideoEnginePlaybackStatePlaying | 1 | 播放中。 |
| TTVideoEnginePlaybackStatePaused | 2 | 播放暂停。 |
| TTVideoEnginePlaybackStateError | 3 | 播放错误。 |
typedef NS_ENUM( NSUInteger, TTVideoEngineNetworkType )
网络类型。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineNetworkTypeWifi | 0 | 使用 WiFi。 |
| TTVideoEngineNetworkTypeNotWifi | 1 | 使用非 WiFi。 |
| TTVideoEngineNetworkTypeNone | 2 | 未知状态。 |
typedef NS_ENUM( NSInteger, TTVideoEngineDownloadState )
下载状态。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineDownloadStateInit | 0 | 初始化。 |
| TTVideoEngineDownloadStateWaiting | 1 | 等待中。 |
| TTVideoEngineDownloadStateRunning | 2 | 运行中。 |
| TTVideoEngineDownloadStateSuspended | 3 | 暂停。 |
| TTVideoEngineDownloadStateCanceling | 4 | 正在取消。 |
| TTVideoEngineDownloadStateCompleted | 5 | 完成。 |
typedef NS_OPTIONS( NSInteger, TTVideoEngineLogFlag )
播放器输出日志模块。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineLogFlagNone | 0 | 不输出日志。 |
| TTVideoEngineLogFlagEngine | 1 << 0 | 输出 Engine 日志。 |
| TTVideoEngineLogFlagPlayer | 1 << 1 | 输出播放内核日志。 |
| TTVideoEngineLogFlagMDL | 1 << 2 | 输出数据加载模块日志。 |
| TTVideoEngineLogFlagDefault | TTVideoEngineLogFlagAlogEngine | TTVideoEngineLogFlagAlogMDL | TTVideoEngineLogFlagAlogPlayer | TTVideoEngineLogFlagAlogPlaylistCacheModule | 输出 Engine、内核、数据加载模块日志。 |
@protocol TTVideoEngineExternDNSParserDataSource<NSObject>
该协议描述使用外部自定义 DNS 解析 DataSource。
| 返回 | 名称 |
|---|---|
| NSString* | hostName |
| NSArray* | ipList |
| NSInteger | ttl |
- (NSString *)hostName;
解析的域名。
- (NSArray *)ipList;
域名解析出的 IP 列表。
- (NSInteger)ttl;
解析过期时间,单位:秒。
typedef NS_ENUM( NSInteger, TTVideoEngineMirrorType )
镜像模式。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineMirrorTypeNone | 0 | 无镜像。 |
| TTVideoEngineMirrorTypeHorizontal | 1 | 水平镜像。 |
| TTVideoEngineMirrorTypeVertical | 2 | 垂直镜像。 |
| TTVideoEngineMirrorTypeHV | 3 | 同时开启水平镜像和垂直镜像。 |
@interface TTVideoEngineVidSource : NSObject <TTVideoEngineMediaSource>
Vid 播放源。
| 类型 | 名称 |
|---|---|
| NSString* | vid |
| NSString* | playAuthToken |
| NSString* | subtitleAuthToken |
| TTVideoEngineResolutionType | resolution |
| TTVideoEngineEncodeType | encodeType |
| BOOL | isDash |
| BOOL | isHLS |
| NSDictionary* | urlExtendParams |
| NSDictionary<NSString*,NSString*>* | customHeaders |
| 返回 | 名称 |
|---|---|
| TTVideoEngineResolutionType | preloadVideoResolution |
| TTVideoEngineSubProtocol | preloadSubtitleModelBlock |
| instancetype | initWithVid:playAuthToken:resolution: |
| instancetype | initWithVid:playAuthToken:resolution:encodeType:isDash:isHLS: |
@property (nonatomic, copy) NSString *vid;
(必需)设置视频 ID。
@property (nonatomic, copy) NSString *playAuthToken;
(必需)设置用于鉴权的 playAuthToken。这是由应用服务端签算并下发给客户端的,详见客户端播放。
@property (nonatomic, copy) NSString *subtitleAuthToken;
设置用于鉴权的 subtitleAuthToken。这是由应用服务端签算并下发给客户端的。
@property (nonatomic, assign) TTVideoEngineResolutionType resolution;
设置视频分辨率,详见 TTVideoEngineResolutionType 。
@property (nonatomic, assign) TTVideoEngineEncodeType encodeType;
设置视频编码格式,详见 TTVideoEngineEncodeType 。默认为 H.264。
@property (nonatomic, assign) BOOL isDash;
设置是否为 DASH。默认为 NO。
@property (nonatomic, assign) BOOL isHLS;
设置是否为 HLS。默认为 NO。
@property (nonatomic, strong, nullable) NSDictionary *urlExtendParams;
设置视频播放地址扩展参数。
@property (nonatomic, strong, nullable) NSDictionary<NSString *, NSString *> *customHeaders;
播放或预加载的自定义 headers。
@property (nonatomic, strong, nullable) TTVideoEngineResolutionType (^preloadVideoResolution)(void);
获取预加载档位,默认使用 resolution 设置的值,如果业务播放过程中切换档位,可以使用该回调同步修改预加载档位。
@property (nonatomic, strong, nullable) id<TTVideoEngineSubProtocol> (^preloadSubtitleModelBlock)(NSArray<id<TTVideoEngineSubProtocol>> *subModels);
获取缓存预加载 subtitle model。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| subModels | NSArray<id | - |
- (instancetype)initWithVid:(NSString *)vid playAuthToken:(NSString *)playAuthToken resolution:(TTVideoEngineResolutionType)resolution;
初始化 Vid 播放源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| vid | NSString* | 视频 ID。 |
| playAuthToken | NSString* | (必需)视频 playAuthToken。这是由应用服务端签算并下发给客户端的,详见客户端播放。 |
| resolution | TTVideoEngineResolutionType | 视频分辨率,详见 TTVideoEngineResolutionType 。 |
返回值
Vid 播放源实例。
Vid 播放源实例。
- (instancetype)initWithVid:(NSString *)vid playAuthToken:(NSString *)playAuthToken resolution:(TTVideoEngineResolutionType)resolution encodeType:(TTVideoEngineEncodeType)encodeType isDash:(BOOL)isDash isHLS:(BOOL)isHLS;
初始化 Vid 播放源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| vid | NSString* | 视频 ID。 |
| playAuthToken | NSString* | (必需)视频 playAuthToken。这是由应用服务端签算并下发给客户端的,详见客户端播放。 |
| resolution | TTVideoEngineResolutionType | 视频分辨率,详见 TTVideoEngineResolutionType 。 |
| encodeType | TTVideoEngineEncodeType | 视频编码格式,详见 TTVideoEngineEncodeType 。默认为 H.264。 |
| isDash | BOOL | 是否为 DASH。默认为 NO。 |
| isHLS | BOOL | 是否为 HLS。默认为 NO。 |
返回值
Vid 播放源实例。
typedef NS_ENUM( NSUInteger, TTVideoEngineResolutionType )
视频清晰度。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineResolutionTypeSD | 0 | 标清 360P |
| TTVideoEngineResolutionTypeHD | 1 | 高清 480P |
| TTVideoEngineResolutionTypeFullHD | 2 | 超清 720P |
| TTVideoEngineResolutionType1080P | 3 | 1080P |
| TTVideoEngineResolutionType4K | 4 | 4K |
| TTVideoEngineResolutionTypeAuto | 5 | 自动调节。该选项仅适用于 DASH 视频,表示根据网速动态调节清晰度。 |
| TTVideoEngineResolutionTypeHD_H | 8 | 540P |
| TTVideoEngineResolutionType2K | 10 | 2K |
@interface TTVideoEnginePreloaderURLItem : TTVideoEnginePreloaderItem
DirectUrl 播放源预加载信息。
| 类型 | 名称 |
|---|---|
| NSString* | key |
| NSArray<NSString*>* | urls |
| NSString* | videoId |
| NSString* | cacheFilePath |
| NSInteger | preloadSize |
| NSInteger | priorityLevel |
| NSString* | decryptionKey |
| BOOL | isForceUseHLSProxy |
@property (nonatomic, copy, nullable) NSString *key;
(必需)设置预加载任务唯一标识。建议使用 URL MD5 值作为 key。如果使用 URL MD5 值作为 key,需要注意某些 URL 可能会包含时间戳或签名等信息,在使用之前需要将这些可变部分去除,以保证使用的是不变的 URL 的 MD5 值。
@property (nonatomic, copy, nullable) NSArray<NSString *> *urls;
(必需)设置预加载视频源的 URL。支持主备 URL。
@property (nonatomic, copy, nullable) NSString *videoId;
(必需)视频的唯一标识,必须与视频源一一对应。可以是您自己的视频管理系统中的视频唯一标识,也可以跟 key 赋值一样。
@property (nonatomic, copy, nullable) NSString *cacheFilePath;
指定缓存路径。SDK 有默认缓存路径,不建议您单独设置。
@property (nonatomic, assign) NSInteger preloadSize;
设置预加载数据大小,例如 800 * 1024 代表预加载 800k 数据。
@property (nonatomic, assign) NSInteger priorityLevel;
预加载优先级,默认为 TTVideoEnginePrloadPriorityDefault。
@property (nonatomic, strong, nullable) NSString *decryptionKey;
自定义私有加密密钥。用于播放加密视频。
@property (nonatomic, assign) BOOL isForceUseHLSProxy;
强制指定为hls源,通常情况下不建议使用。
@interface TTVideoEngineStrategyPreloadConfig : NSObject
自定义预加载策略配置。
| 类型 | 名称 |
|---|---|
| NSInteger | count |
| NSInteger | size |
| NSInteger | startBufferLimit |
| NSInteger | stopBufferLimit |
@property (nonatomic, assign) NSInteger count;
设置预加载视频个数。
注意
建议设置 3 - 5 个,SDK 内部限制最多 10 个,设置过多可能会带来成本浪费。
@property (nonatomic, assign) NSInteger size;
设置预加载视频大小,单位为(KB)。
注意
短视频场景建议设置 500 - 800K。您可根据视频时长调整,确保可以加载出视频首帧。
@property (nonatomic, assign) NSInteger startBufferLimit;
设置预加载任务开始时机。
注意
播放器缓冲 buffer 大于设置时长才会开始预加载。建议设置 15 秒以上。
@property (nonatomic, assign) NSInteger stopBufferLimit;
设置预加载任务停止时机。
注意
播放器缓冲 buffer 小于设置时长才会停止预加载,并取消当前的预加载任务。建议设置 5 秒左右。
typedef NS_ENUM( NSUInteger, TTVideoEngineDataLoaderErrorType )
视频数据加载错误。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineDataLoaderErrorNone | 0 | 默认值。 |
| TTVideoEngineDataLoaderErrorFetchVideoInfo | 1 | 获取视频信息时发生错误。 |
| TTVideoEngineDataLoaderErrorStart | 2 | 启动数据加载模块时发生错误。 |
| TTVideoEngineDataLoaderErrorFetchData | 3 | 下载数据时发生错误。 |
| TTVideoEngineDataLoaderErrorWriteFile | 4 | 写数据时发生错误。 |
@interface TTVideoEngineLocalServerTaskInfo : NSObject
数据加载模块中的缓存任务信息。
| 类型 | 名称 |
|---|---|
| NSString* | key |
| NSString* | videoId |
| TTVideoEngineResolutionType | resolution |
| NSString* | localFilePath |
| int64_t | mediaSize |
| int64_t | preloadSize |
| TTVideoEngineURLInfo* | urlInfo |
@property (nonatomic, copy) NSString *key;
视频源唯一标识。
@property (nonatomic, nullable, copy) NSString *videoId;
视频 ID。
@property (nonatomic, assign) TTVideoEngineResolutionType resolution;
视频源分辨率,详见 TTVideoEngineResolutionType 。
@property (nonatomic, nullable, copy) NSString *localFilePath;
本地缓存路径。
@property (nonatomic, assign) int64_t mediaSize;
视频源大小,单位:byte。
@property (nonatomic, assign) int64_t preloadSize;
预加载数据大小,单位:byte。
@property (nonatomic, nullable, strong) TTVideoEngineURLInfo *urlInfo;
视频源 URL 信息,仅预加载 Vid 播放源时有值。
typedef NS_ENUM( NSInteger, TTVideoEngineStrategyType )
播放器策略类型。SDK 支持多种策略,可以单个开启使用,也可以组合使用。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineStrategyTypeNone | 1 << 0 | - |
| TTVideoEngineStrategyTypeCommon | 1 << 1 | - |
| TTVideoEngineStrategyTypePreload | 1 << 2 | - |
| TTVideoEngineStrategyTypePreRender | 1 << 3 | - |
typedef NS_ENUM( NSInteger, TTVideoEngineSourceType )
播放源类型。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineSourceTypeVideoId | 0 | 使用 Vid 播放源。 |
| TTVideoEngineSourceTypeDirectUrl | 1 | 使用 DirectUrl 播放源。 |
| TTVideoEngineSourceTypeVideoModel | 2 | 使用 VideoModel 播放源,需要按照 VideoModel 的格式组装播放源数据。 |
typedef NS_ENUM( NSUInteger, TTVideoEngineSeekModeType )
Seek 类型。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineSeekModeAccurateAny | 0 | 精准 Seek。 |
| TTVideoEngineSeekModeInAccurateBackWard | 1 | 非精准 Seek,有助于提升起播速度。 |
typedef NS_ENUM( NSUInteger, TTVideoEngineAudioChannelType )
音频左右声道。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineAudioChannelNormal | 0 | 默认双声道。 |
| TTVideoEngineAudioChannelRightDisable | 1 | 关闭右声道。 |
| TTVideoEngineAudioChannelLeftDisable | 2 | 关闭左声道。 |
| TTVideoEngineAudioChannelLeftUesdForLR | 3 | 使用左声道数据播放左右声道。 |
| TTVideoEngineAudioChannelRightUesdForLR | 4 | 使用右声道数据播放左右声道。 |
typedef NS_ENUM( NSUInteger, TTVideoEngineStallReason )
播放器卡顿原因。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineStallReasonNone | 0 | 默认值。 |
| TTVideoEngineStallReasonNetwork | 1 | 播放器因为网络原因导致卡顿。 |
| TTVideoEngineStallReasonDecoder | 2 | 播放器因为解码器异常导致卡顿。 |
@protocol TTVideoEngineMediaSource <NSObject>
定义播放源的接口。
| 类型 | 名称 |
|---|---|
| NSString* | uniqueId |
| TTVideoEngineSourceType | sourceType |
| BOOL | enableFallbackRefresh |
| NSDictionary<NSString*,NSString*>* | customHeaders |
@property (nonatomic, readonly, strong, getter=getUniqueId) NSString *uniqueId;
当前播放源的唯一标识。
TTVideoEngineSourceTypeVideoId 类型和 TTVideoEngineSourceTypeVideoModel 类型的播放源使用 vid 作为唯一标识。
TTVideoEngineSourceTypeDirectUrl 类型的播放源使用 cacheKey 作为唯一标识。
@property (nonatomic, assign) TTVideoEngineSourceType sourceType;
设置播放源类型,详见 TTVideoEngineSourceType 。
@property (nonatomic, assign) BOOL enableFallbackRefresh;
开启播放过程中播放 URL 地址过期自动刷新功能。
注意
开启该功能后,您需要实现 TTVideoURLRefreshFetcher 协议对象,并通过 [TTVideoEngine urlRefreshFetcher] 设置给 TTVideoEngine 播放器实例。
@property (nonatomic, strong, nullable) NSDictionary<NSString *, NSString *> *customHeaders;
播放或预加载的自定义 headers。
typedef NS_ENUM( NSInteger, TTVideoEngineUserAction )
用户控制播放器动作。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineUserActionInit | 0 | 初始化播放器。 |
| TTVideoEngineUserActionPrepare | 1 | 调用 prepare。 |
| TTVideoEngineUserActionPlay | 2 | 调用 play。 |
| TTVideoEngineUserActionPause | 3 | 调用 pause。 |
| TTVideoEngineUserActionStop | 4 | 调用 stop。 |
| TTVideoEngineUserActionClose | 5 | 调用 close。 |
typedef NS_ENUM( NSUInteger, TTVideoEngineAudioEffectType )
音频效果。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineAudioEffectRTCLoudNorm | 4 | 音量均衡。 |
@interface TTVideoEngineSubDecInfoModel : NSObject <TTVideoEngineSubDecInfoProtocol>
所有语言的字幕数据源,遵守 TTVideoEngineSubDecInfoProtocol 协议。
| 类型 | 名称 |
|---|---|
| NSMutableArray<id | subModels |
| 返回 | 名称 |
|---|---|
| instancetype | initWithDictionary: |
| instancetype | initWithSubModels: |
| void | addSubModel: |
| NSString* | jsonString |
| NSInteger | subtitleCount |
@property (nonatomic, strong, readonly) NSMutableArray<id<TTVideoEngineSubProtocol>> *subModels;
所有字幕源列表。
- (instancetype)initWithDictionary:(NSDictionary *_Nonnull)dict;
初始化所有语言的字幕数据源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| dict | NSDictionary* | Dictionary 格式的字幕数据源。 |
返回值
返回字幕数据源 Model。
- (instancetype)initWithSubModels:(NSArray<id<TTVideoEngineSubProtocol>> *_Nonnull)models;
初始化所有语言的字幕数据源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| models | NSArray<id | 字幕数据源 TTVideoEngineSubModel 数组。 |
返回值
返回字幕数据源 TTVideoEngineSubDecInfoModel 实例。
- (void)addSubModel:(id<TTVideoEngineSubProtocol> _Nonnull)model;
增加单个语言的字幕数据源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| model | id<TTVideoEngineSubProtocol> | 单个语言的字幕数据源 TTVideoEngineSubDecInfoModel 。 |
- (NSString *_Nullable)jsonString;
获取字幕源 JSON String。
返回值
返回字幕源 JSON String。
- (NSInteger)subtitleCount;
获取字幕源个数。
返回值
返回字幕源个数。
@interface TTVideoEnginePreloaderVidItem : TTVideoEnginePreloaderItem
Vid 播放源预加载信息。
| 类型 | 名称 |
|---|---|
| NSString* | videoId |
| NSString* | playAuthToken |
| TTVideoEngineResolutionType | resolution |
| NSInteger | preloadSize |
| TTVideoEngineEncodeType | codecType |
| BOOL | encryptionEnable |
| BOOL | hlsEnable |
| NSInteger | priorityLevel |
| NSDictionary* | urlExtendParams |
@property (nonatomic, nullable, copy) NSString *videoId;
(必需)设置视频 ID。
@property (nonatomic, copy) NSString *playAuthToken;
(必需)设置视频 playAuthToken。这是由应用服务端签算并下发给客户端的,详见客户端播放。
@property (nonatomic, assign) TTVideoEngineResolutionType resolution;
(必需)设置预加载视频分辨率,详见 TTVideoEngineResolutionType 。预加载视频分辨率要和播放的分辨率保持一致,这样才会命中预加载。
@property (nonatomic, assign) NSInteger preloadSize;
设置预加载数据大小,例如 800 * 1024 代表预加载 800k 数据。
@property (nonatomic, assign) TTVideoEngineEncodeType codecType;
设置预加载视频源的编码格式,详见 TTVideoEngineEncodeType ,默认为 TTVideoEngineH264。
@property (nonatomic, assign) BOOL encryptionEnable;
预加载视频源是否加密。
@property (nonatomic, assign) BOOL hlsEnable;
预加载视频源是否为 HLS。
@property (nonatomic, assign) NSInteger priorityLevel;
预加载优先级,默认为 TTVideoEnginePrloadPriorityDefault。
@property (nonatomic, strong, nullable) NSDictionary *urlExtendParams;
设置视频播放地址扩展参数。
typedef NS_ENUM( NSInteger, TTVideoEngineRotateType )
播放器旋转角度。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineRotateTypeNone | 0 | 无旋转。 |
| TTVideoEngineRotateType90 | 1 | 90 度旋转。 |
| TTVideoEngineRotateType180 | 2 | 180 度旋转。 |
| TTVideoEngineRotateType270 | 3 | 270 度旋转。 |
@interface TTVideoEngineUrlSource : NSObject <TTVideoEngineMediaSource>
DirectUrl 播放源。
| 类型 | 名称 |
|---|---|
| NSArray* | urls |
| NSString* | cacheKey |
| TTVideoEngineEncodeType | encodeType |
| NSString* | vid |
| NSDictionary<NSString*,NSString*>* | customHeaders |
| NSInteger | subtitleId |
| TTVideoEngineSubDecInfoModel* | subtitleInfoModel |
| BOOL | isHDRSource |
| BOOL | enableFallbackRefresh |
| NSString* | format |
| NSInteger | bitrate |
| NSString* | decryptionKey |
| NSString* | filePath |
@property (nonatomic, strong) NSArray *urls;
视频 URL。支持备用 URL。
@property (nonatomic, copy) NSString *cacheKey;
缓存 key。这是 URL 对应的唯一标识,需遵循以下规则:
不带特殊字符,能作为文件名。
能和视频资源文件一一对应。
建议使用 URL 的 MD5 值。
@property (nonatomic, assign) TTVideoEngineEncodeType encodeType;
视频编码格式,详见 TTVideoEngineEncodeType 。
@property (nonatomic, copy, nullable) NSString *vid;
视频 ID。
@property (nonatomic, strong, nullable) NSDictionary<NSString *, NSString *> *customHeaders;
播放或预加载的自定义 headers。
@property (nonatomic, assign) NSInteger subtitleId;
字幕Id。
@property (nonatomic, strong, nullable) TTVideoEngineSubDecInfoModel *subtitleInfoModel;
字幕源。
@property (nonatomic, assign) BOOL isHDRSource;
是否为 HDR。
@property (nonatomic, assign) BOOL enableFallbackRefresh;
开启播放过程中播放 URL 地址过期自动刷新功能。
注意
开启该功能后,您需要实现 TTVideoURLRefreshFetcher 协议对象,并通过 [TTVideoEngine urlRefreshFetcher] 设置给 TTVideoEngine 播放器实例。
@property (nonatomic, copy) NSString *format;
视频封装格式,例如 mp4。
@property (nonatomic, assign) NSInteger bitrate;
视频码率。
@property (nonatomic, strong, nullable) NSString *decryptionKey;
自定义密钥。用于播放加密视频。
@property (nonatomic, copy, nullable) NSString *filePath;
文件路径。
- (instancetype)initWithUrl:(NSString *)url cacheKey:(NSString *)cacheKey;
初始化 DirectUrl 播放源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| url | NSString* | 视频 URL。 |
| cacheKey | NSString* | 缓存 key。这是 URL 对应的唯一标识,需遵循以下规则:
|
返回值
DirectUrl 播放源实例。
- (instancetype)initWithUrls:(NSArray *)urls cacheKey:(NSString *)cacheKey;
初始化 DirectUrl 播放源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| urls | NSArray* | 视频 URL 列表。支持备用 URL。 |
| cacheKey | NSString* | 缓存 key。这是 URL 对应的唯一标识,需遵循以下规则:
|
返回值
DirectUrl 播放源实例。
- (instancetype)initWithUrls:(NSArray *)urls cacheKey:(NSString *)cacheKey videoId:(NSString * _Nullable)vid encodeType:(TTVideoEngineEncodeType)encodeType decryptionKey:(NSString * _Nullable)decryptionKey filePath:(NSString * _Nullable)filePath isHDRSource:(BOOL)isHDRSource;
初始化 DirectUrl 播放源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| urls | NSArray* | 视频 URL 列表。支持备用 URL。 |
| cacheKey | NSString* | 缓存 key。这是 URL 对应的唯一标识,需遵循以下规则:
|
| vid | NSString* | - |
| encodeType | TTVideoEngineEncodeType | 视频编码格式,详见 TTVideoEngineEncodeType 。 |
| decryptionKey | NSString* | 自定义密钥。用于播放加密视频。 |
| filePath | NSString* | 视频存储路径,可与 cacheKey 二选一。 |
| isHDRSource | BOOL | 是否为 HDR。 |
返回值
DirectUrl 播放源实例。
- (void)addUrls:(NSArray *)urls cacheKey:(NSString *)cacheKey encodeType:(TTVideoEngineEncodeType)encodeType decryptionKey:(NSString * _Nullable)decryptionKey filePath:(NSString * _Nullable)filePath isHDRSource:(BOOL)isHDRSource;
添加 DirectUrl 播放源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| urls | NSArray* | 视频 URL 列表。支持备用 URL。 |
| cacheKey | NSString* | 缓存 key。这是 URL 对应的唯一标识,需遵循以下规则:
|
| encodeType | TTVideoEngineEncodeType | 视频编码格式,详见 TTVideoEngineEncodeType 。 |
| decryptionKey | NSString* | 自定义密钥。用于播放加密视频。 |
| filePath | NSString* | 视频存储路径,可与 cacheKey 二选一。 |
| isHDRSource | BOOL | 是否为 HDR 源。 |
typedef NS_ENUM( NSInteger, TTVideoEngineVideoModelSourceType )
视频格式。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineVideoModelSourceTypeUnkonw | 0 | 未知 |
| TTVideoEngineVideoModelSourceTypeMp4 | 1 | MP4 |
| TTVideoEngineVideoModelSourceTypeDash | 10 | DASH |
| TTVideoEngineVideoModelSourceTypeBash | 11 | BASH |
@interface TTVideoEnginePreloaderVideoModelItem (PreloadItem)
VideoModel 视频源预加载 item。
| 返回 | 名称 |
|---|---|
| nullable instancetype | videoModelItemWithVideoSource:preloadSize:params: |
+ (nullable instancetype)videoModelItemWithVideoSource:(id<TTVideoEngineMediaSource>)source preloadSize:(NSInteger)preloadSize params:(nullable NSDictionary *)params;
构建一个 VideoModel 播放源预加载 Item 实例。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| source | id<TTVideoEngineMediaSource> | VideoModel 播放源。 |
| preloadSize | NSInteger | 预加载数据大小,例如 800 * 1024 代表预加载 800k 数据。 |
| params | nullable NSDictionary* | 扩展参数,您无需设置。 |
返回值
返回 VideoModel 播放源预加载 Item 实例。
@interface TTVideoEngineSubModel : NSObject <TTVideoEngineSubProtocol>
单个语言的字幕数据源,遵守 TTVideoEngineSubProtocol 协议。
| 类型 | 名称 |
|---|---|
| NSInteger | index |
| NSString* | language |
| NSInteger | expireTime |
| NSString* | cacheKey |
| 返回 | 名称 |
|---|---|
| instancetype | initWithDictionary: |
| NSDictionary* | toDictionary |
| NSString* | jsonString |
@property (nonatomic, assign, readonly) NSInteger index;
当前字幕 index。
@property (nonatomic, copy, readonly) NSString *language;
字幕语言,详见字幕语言。
@property (nonatomic, assign, readonly) NSInteger expireTime;
字幕过期时间戳。精度为毫秒的 Unix 时间戳。
@property (nonatomic, copy, readonly) NSString *cacheKey;
本地缓存唯一标识。
- (instancetype)initWithDictionary:(NSDictionary * _Nonnull)dict;
初始化单个语言的字幕数据源。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| dict | NSDictionary* | 字幕数据源。 |
返回值
返回单个语言的字幕源数据 TTVideoEngineSubModel 。
- (NSDictionary *_Nullable)toDictionary;
将字幕数据源 Model 转换为 Dictionary。
- (NSString *_Nullable)jsonString;
将字幕数据源 Model 转换为 JSON String。
@interface TTVideoEnginePreloaderVideoModelItem : TTVideoEnginePreloaderItem
VideoModel 播放源预加载信息。
| 类型 | 名称 |
|---|---|
| TTVideoEngineResolutionType | resolution |
| TTVideoEngineModel* | videoModel |
| NSInteger | preloadSize |
| NSInteger | priorityLevel |
@property (nonatomic, assign) TTVideoEngineResolutionType resolution;
设置视频源分辨率,详见 TTVideoEngineResolutionType 。
@property (nonatomic, strong, nullable) TTVideoEngineModel *videoModel;
设置视频源信息。
@property (nonatomic, assign) NSInteger preloadSize;
设置预加载数据大小,单位:byte。例如 800 * 1024 代表预加载 800k 数据。
@property (nonatomic, assign) NSInteger priorityLevel;
预加载优先级,默认为 TTVideoEnginePrloadPriorityDefault。
typedef NS_ENUM( NSInteger, TTVideoEngineEncodeType )
视频编码类型。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineH264 | 0 | H.264 |
| TTVideoEngineh265 | 3 | H.265 |
typedef NS_ENUM( NSUInteger, TTVideoEngineRenderEngine )
视频渲染方式。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineRenderEngineOpenGLES | 0 | OpenGLES 渲染。 |
| TTVideoEngineRenderEngineMetal | 1 | Metal 渲染。 |
| TTVideoEngineRenderEngineOutput | 2 | 业务外部渲染,不使用 SDK 渲染。 |
@interface TTVideoEnginePreloaderVidItem (PreloadItem)
VID 视频源预加载 item。
| 返回 | 名称 |
|---|---|
| nullable instancetype | vidItemWithVideoSource:preloadSize: |
+ (nullable instancetype)vidItemWithVideoSource:(id<TTVideoEngineMediaSource>)source preloadSize:(NSInteger)preloadSize;
构建一个 Vid 播放源预加载 Item 实例。
传入参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| source | id<TTVideoEngineMediaSource> | Vid 播放源。 |
| preloadSize | NSInteger | 预加载数据大小,单位:byte。例如 800 * 1024 代表预加载 800k 数据。 |
返回值
返回 Vid 播放源预加载 Item 实例。
typedef NS_ENUM( NSInteger, TTVideoEngineScalingMode )
播放器缩放模式。
| 类型 | 值 | 说明 |
|---|---|---|
| TTVideoEngineScalingModeNone | 0 | 无拉伸,不会变形,可能有黑边。 |
| TTVideoEngineScalingModeAspectFit | 1 | 按照视频宽高等比适配画面,不会变形,可能有黑边。 |
| TTVideoEngineScalingModeAspectFill | 2 | 按照视频宽高等比填充画面,不会变形,可能有画面裁剪。 |
| TTVideoEngineScalingModeFill | 3 | - |
@protocol TTVideoEngineSubProtocol <NSObject>
单个语言的字幕数据源协议。
| 类型 | 名称 |
|---|---|
| NSInteger | languageId |
| NSString* | urlString |
| NSString* | format |
| NSInteger | subtitleId |
| NSString* | cacheKey |
| 返回 | 名称 |
|---|---|
| NSDictionary* | toDictionary |
| NSString* | jsonString |
@property (nonatomic, assign, readonly) NSInteger languageId;
字幕语言 ID。详见字幕语言。
@property (nonatomic, copy, readonly) NSString *urlString;
字幕 URL 地址。
@property (nonatomic, copy, readonly) NSString *format;
字幕格式。
@property (nonatomic, assign, readonly) NSInteger subtitleId;
字幕 ID。
@property (nonatomic, copy, readonly) NSString *cacheKey;
本地缓存唯一标识。
- (NSDictionary *_Nullable)toDictionary;
将字幕数据源 Model 转换为 Dictionary。
- (NSString *_Nullable)jsonString;
将字幕数据源 Model 转换为 JSON String。
@protocol TTVideoEngineSubDecInfoProtocol <NSObject>
所有语言的字幕数据源协议。
| 返回 | 名称 |
|---|---|
| NSString* | jsonString |
| NSInteger | subtitleCount |
- (NSString *_Nullable)jsonString;
注入 JSON 格式的字幕数据源。
返回值
返回 JSON 格式的字幕源数据。
- (NSInteger)subtitleCount;
获取字幕语言的个数。
返回值
返回字幕语言的个数。