TXVodPlayer.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //
  2. // TXVodPlayer.h
  3. // TXLiteAVSDK
  4. //
  5. // Created by annidyfeng on 2017/9/12.
  6. // Copyright © 2017年 Tencent. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import "TXLivePlayListener.h"
  11. #import "TXVodPlayListener.h"
  12. #import "TXVodPlayConfig.h"
  13. #import "TXVideoCustomProcessDelegate.h"
  14. #import "TXBitrateItem.h"
  15. #import "TXPlayerAuthParams.h"
  16. /// @defgroup TXVodPlayer_ios TXVodPlayer
  17. /// 点播播放器
  18. /// @{
  19. @interface TXVodPlayer : NSObject
  20. /**
  21. * 事件回调
  22. * @warning 建议使用vodDelegate
  23. */
  24. @property(nonatomic, weak) id <TXLivePlayListener> delegate __attribute__((deprecated("use vodDelegate instead")));
  25. /// 事件回调
  26. @property(nonatomic, weak) id <TXVodPlayListener> vodDelegate;
  27. /**
  28. * 视频渲染回调。(仅硬解支持)
  29. */
  30. @property(nonatomic, weak) id <TXVideoCustomProcessDelegate> videoProcessDelegate;
  31. /**
  32. * 是否开启硬件加速
  33. * 播放前设置有效
  34. */
  35. @property(nonatomic, assign) BOOL enableHWAcceleration;
  36. /**
  37. * 点播配置
  38. */
  39. @property(nonatomic, copy) TXVodPlayConfig *config;
  40. /// startPlay后是否立即播放,默认YES
  41. @property BOOL isAutoPlay;
  42. /**
  43. * 加密HLS的token。设置此值后,播放器自动在URL中的文件名之前增加 voddrm.token.TOKEN
  44. */
  45. @property (nonatomic, strong) NSString *token;
  46. /* setupContainView 创建Video渲染View,该控件承载着视频内容的展示。
  47. * @param view 父view
  48. * @param idx Widget在父view上的层级位置
  49. */
  50. - (void)setupVideoWidget:(UIView *)view insertIndex:(unsigned int)idx;
  51. /**
  52. * 移除Video渲染View
  53. */
  54. - (void)removeVideoWidget;
  55. /**
  56. * 设置播放开始时间
  57. * 在startPlay前设置,修改开始播放的起始位置
  58. */
  59. - (void)setStartTime:(CGFloat)startTime;
  60. /**
  61. * startPlay 启动从指定URL播放
  62. *
  63. * @param url 完整的URL(如果播放的是本地视频文件,这里传本地视频文件的完整路径)
  64. * @return 0 = OK
  65. */
  66. - (int)startPlay:(NSString *)url;
  67. /**
  68. * 通过fileid方式播放。
  69. *
  70. * fileid的获取方式可参考 [启动播放](https://cloud.tencent.com/document/product/454/12148#step-3.3A-.E5.90.AF.E5.8A.A8.E6.92.AD.E6.94.BE)
  71. *
  72. * @param params 认证参数
  73. * @return 0 = OK
  74. */
  75. - (int)startPlayWithParams:(TXPlayerAuthParams *)params;
  76. /**
  77. * 停止播放音视频流
  78. * @return 0 = OK
  79. */
  80. - (int)stopPlay;
  81. /**
  82. * 是否正在播放
  83. */
  84. - (bool)isPlaying;
  85. /**
  86. * 暂停播放
  87. */
  88. - (void)pause;
  89. /**
  90. * 继续播放
  91. */
  92. - (void)resume;
  93. /**
  94. * 播放跳转到音视频流某个时间
  95. * @param time 流时间,单位为秒
  96. * @return 0 = OK
  97. */
  98. - (int)seek:(float)time;
  99. /**
  100. * 获取当前播放时间
  101. */
  102. - (float)currentPlaybackTime;
  103. /**
  104. * 获取视频总时长
  105. */
  106. - (float)duration;
  107. /**
  108. * 可播放时长
  109. */
  110. - (float)playableDuration;
  111. /**
  112. * 视频宽度
  113. */
  114. - (int)width;
  115. /**
  116. * 视频高度
  117. */
  118. - (int)height;
  119. /**
  120. * 设置画面的方向
  121. * @param rotation 方向
  122. * @see TX_Enum_Type_HomeOrientation
  123. */
  124. - (void)setRenderRotation:(TX_Enum_Type_HomeOrientation)rotation;
  125. /**
  126. * 设置画面的裁剪模式
  127. * @param renderMode 裁剪
  128. * @see TX_Enum_Type_RenderMode
  129. */
  130. - (void)setRenderMode:(TX_Enum_Type_RenderMode)renderMode;
  131. /**
  132. * 设置静音
  133. */
  134. - (void)setMute:(BOOL)bEnable;
  135. /*
  136. * 截屏
  137. * @param snapshotCompletionBlock 通过回调返回当前图像
  138. */
  139. - (void)snapshot:(void (^)(UIImage *))snapshotCompletionBlock;
  140. /**
  141. * 设置播放速率
  142. * @param rate 正常速度为1.0;小于为慢速;大于为快速。最大建议不超过2.0
  143. */
  144. - (void)setRate:(float)rate;
  145. /**
  146. * 当播放地址为master playlist,返回支持的码率(清晰度)
  147. *
  148. * @warning 在收到EVT_VIDEO_PLAY_BEGIN事件后才能正确返回结果
  149. * @return 无多码率返回空数组
  150. */
  151. - (NSArray<TXBitrateItem *> *)supportedBitrates;
  152. /**
  153. * 获取当前正在播放的码率索引
  154. */
  155. - (NSInteger)bitrateIndex;
  156. /**
  157. * 设置当前正在播放的码率索引,无缝切换清晰度
  158. * 清晰度切换可能需要等待一小段时间。腾讯云支持多码率HLS分片对齐,保证最佳体验。
  159. *
  160. * @param index 码率索引
  161. */
  162. - (void)setBitrateIndex:(NSInteger)index;
  163. /**
  164. * 设置画面镜像
  165. */
  166. - (void)setMirror:(BOOL)isMirror;
  167. /**
  168. * 是否循环播放
  169. */
  170. @property (nonatomic, assign) BOOL loop;
  171. @end
  172. /// @}