TXVodPlayer.h 4.1 KB

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