腾讯云直播播放器接口类
| class TXLivePlayer |
SDK 基础函数 | |
| id< TXLivePlayListener > | delegate |
| id< TXVideoCustomProcessDelegate > | videoProcessDelegate |
| id< TXAudioRawDataDelegate > | audioRawDataDelegate |
| BOOL | enableHWAcceleration |
| TXLivePlayConfig * | config |
| id< TXLiveRecordListener > | recordDelegate |
| BOOL | isAutoPlay |
播放基础接口 | |
| (void) | - setupVideoWidget:containView:insertIndex: |
| (void) | - removeVideoWidget |
| (int) | - startLivePlay:type: |
| (int) | - stopPlay |
| (BOOL) | - isPlaying |
| (void) | - pause |
| (void) | - resume |
视频相关接口 | |
| (void) | - setRenderRotation: |
| (void) | - setRenderMode: |
| (void) | - snapshot: |
| (uint64_t) | - getCurrentRenderPts |
音频相关接口 | |
| (void) | - setMute: |
| (void) | - setVolume: |
| (void) | - setAudioVolumeEvaluationListener: |
| (void) | - enableAudioVolumeEvaluation: |
| (void) | + setAudioRoute: |
直播时移相关接口 | |
| (int) | - prepareLiveSeek:bizId: |
| (int) | - resumeLive |
| (int) | - seek: |
视频录制相关接口 | |
| (int) | - startRecord: |
| (int) | - stopRecord |
| (void) | - setRate: |
更多实用接口 | |
| (void) | - setLogViewMargin: |
| (void) | - showVideoDebugLog: |
| (int) | - switchStream: |
| (void) | - callExperimentalAPI: |
| - (void) callExperimentalAPI: | (NSString *) | jsonStr |
调用实验性 API 接口
| jsonStr | 接口及参数描述的 JSON 字符串 |
| - (void) enableAudioVolumeEvaluation: | (NSUInteger) | interval |
启用音量大小提示
开启后会在 volumeEvaluationListener 中获取到 SDK 对音量大小值的评估。
| interval | 决定了 volumeEvaluationListener 回调的触发间隔,单位为ms,最小间隔为100ms,如果小于等于0则会关闭回调,建议设置为300ms; |
| - (uint64_t) getCurrentRenderPts |
获取当前渲染帧 pts
| - (BOOL) isPlaying |
是否正在播放
| - (void) pause |
暂停播放
适用于点播,直播(此接口会暂停数据拉流,不会销毁播放器,暂停后,播放器会显示最后一帧数据图像)
| - (int) prepareLiveSeek: | (NSString *) | domain | |
| bizId: | (NSInteger) | bizId | |
直播时移准备,拉取该直播流的起始播放时间。
使用时移功能需在播放开始后调用此方法,否则时移失败。时移的使用请参考文档 超级播放器
| domain | 时移域名 |
| bizId | 流 bizId |
| - (void) removeVideoWidget |
移除 Video 渲染 Widget
| - (void) resume |
继续播放,适用于点播,直播
| - (int) resumeLive |
停止时移播放,返回直播
| - (int) seek: | (float) | time |
播放跳转到音视频流某个时间
| time | 流时间,单位为秒 |
| + (void) setAudioRoute: | (TXAudioRouteType) | audioRoute |
设置声音播放模式(切换扬声器,听筒)
| audioRoute | 声音播放模式 |
| - (void) setAudioVolumeEvaluationListener: | (void(^)(int)) | volumeEvaluationListener |
设置音量大小回调接口
| volumeEvaluationListener | 音量大小回调接口,音量取值范围0 - 100 |
| - (void) setLogViewMargin: | (TXEdgeInsets) | margin |
设置状态浮层 view 在渲染 view 上的边距
| margin | 边距 |
| - (void) setMute: | (BOOL) | bEnable |
设置静音
| - (void) setRate: | (float) | rate |
设置播放速率
| rate | 正常速度为1.0;小于为慢速;大于为快速。最大建议不超过2.0 |
| - (void) setRenderMode: | (TX_Enum_Type_RenderMode) | renderMode |
设置画面的裁剪模式
| renderMode | 裁剪 |
| - (void) setRenderRotation: | (TX_Enum_Type_HomeOrientation) | rotation |
设置画面的方向
| rotation | 方向 |
| - (void) setupVideoWidget: | (CGRect) | frame | |
| containView: | (TXView *) | view | |
| insertIndex: | (unsigned int) | idx | |
创建 Video 渲染 View,该控件承载着视频内容的展示。
变更历史:1.5.2版本将参数 frame 废弃,设置此参数无效,控件大小与参数 view 的大小保持一致,如需修改控件的大小及位置,请调整父 view 的大小及位置。 参考文档:绑定渲染界面
| frame | Widget 在父 view 中的 frame |
| view | 父 view |
| idx | Widget 在父 view 上 的层级位置 |
| - (void) setVolume: | (int) | volume |
设置音量
| volume | 音量大小,取值范围0 - 100 |
| - (void) showVideoDebugLog: | (BOOL) | isShow |
是否显示播放状态统计及事件消息浮层 view
| isShow | 是否显示 |
| - (void) snapshot: | (void(^)(TXImage *)) | snapshotCompletionBlock |
截屏
| snapshotCompletionBlock | 通过回调返回当前图像 |
| - (int) startLivePlay: | (NSString *) | url | |
| type: | (TX_Enum_PlayType) | playType | |
启动从指定 URL 播放 RTMP 音视频流
| url | 完整的 URL(如果播放的是本地视频文件,这里传本地视频文件的完整路径) |
| playType | 播放类型 |
| - (int) startRecord: | (TXRecordType) | recordType |
开始录制短视频
| recordType | 参见 TXRecordType 定义 |
| - (int) stopPlay |
停止播放音视频流
| - (int) stopRecord |
结束录制短视频
| - (int) switchStream: | (NSString *) | playUrl |
FLV 直播无缝切换
| playUrl | 播放地址 |
|
readwritenonatomicweak |
设置音频处理回调,见 “TXAudioRawDataDelegate.h” 文件中的详细定义
|
readwritenonatomiccopy |
设置 TXLivePlayConfig 播放配置项,见 “TXLivePlayConfig.h” 文件中的详细定义
|
readwritenonatomicweak |
设置播放回调,见 “TXLivePlayListener.h” 文件中的详细定义
|
readwritenonatomicassign |
是否开启硬件加速,默认值:NO
|
readwritenonatomicassign |
startLivePlay 后是否立即播放,默认 YES,只有点播有效
|
readwritenonatomicweak |
设置短视频录制回调,见 “TXLiveRecordListener.h” 文件中的详细定义
|
readwritenonatomicweak |
设置视频处理回调,见 “TXVideoCustomProcessDelegate.h” 文件中的详细定义
| enum TX_Enum_PlayType : NSInteger |