BUPlayer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // BUPlayer.h
  3. // BUAdSDK
  4. //
  5. // Created by hlw on 2017/12/21.
  6. // Copyright © 2017年 bytedance. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "BUPlayerDefine.h"
  10. #import "BUPlayerInternalDefine.h"
  11. #import "BUPlayerSettingsProtocol.h"
  12. @class BUPlayerItem;
  13. @interface BUPlayer : NSObject<BUPlayerSettingsProtocol>
  14. @property (nonatomic, weak) id<BUVideoPlayerDelegate> delegate;
  15. @property (nonatomic, weak) id<BUVideoPlayerTimeDelegate> timeDelegate;
  16. /**
  17. * 播放内容视图
  18. */
  19. @property (nonatomic, strong, readonly) UIView *view;
  20. /**
  21. * 播放器状态
  22. * 支持KVO
  23. */
  24. @property (nonatomic, assign, readonly) BUVideoPlayerState state;
  25. /// 播放器播放模式改变
  26. @property (nonatomic, assign, readonly) BUVideoPlayerDecoeMode decodeMode;
  27. /**
  28. * 播放资源总时长
  29. */
  30. @property (nonatomic, assign, readonly) NSTimeInterval duration;
  31. /**
  32. * 当前可播放时长
  33. */
  34. @property (nonatomic, assign, readonly) NSTimeInterval playableDuration;
  35. /**
  36. * 实际观看时长
  37. */
  38. @property (nonatomic, assign, readonly) NSTimeInterval watchedDuration;
  39. /**
  40. * 当前播放时间
  41. */
  42. @property (nonatomic, assign, readonly) CGFloat currentPlayTime;
  43. /// 当前播放链接
  44. @property (nonatomic, strong, readonly) NSURL *currentPlayURL;
  45. /**
  46. * 当前播放资源Item
  47. */
  48. @property (nonatomic, strong, readonly) BUPlayerItem *currentPlayerItem;
  49. /**
  50. * 播放器控制层容器,默认视图支持部分定制或完全自定义
  51. * 默认显示控制层全部元素,可以定制部分视图元素显示/隐藏
  52. * 若完全自定义,需先隐藏全部默认视图元素 再在容器上添加自定义视图
  53. */
  54. @property (nonatomic, strong, readonly) UIView<BUPlayerControlViewProtocol> *controlContainer;
  55. /**
  56. * 播放内容视图填充方式
  57. * 默认:等比例填充,直到一个维度到达区域边界
  58. */
  59. @property (nonatomic, assign) BUPlayerLayerGravity playerLayerGravity;
  60. /**
  61. * 播放视图上手势操作选项开关
  62. * 默认全开
  63. */
  64. @property (nonatomic, assign) BUPlayerGestureOption option;
  65. /**
  66. * 静音设置
  67. */
  68. @property (nonatomic, assign) BOOL mute;
  69. /**
  70. * 当前是否全屏显示
  71. */
  72. @property (nonatomic, assign, readonly) BOOL isFullScreen;
  73. /** 设置自定义ControlView */
  74. @property (nonatomic, strong) UIView *controlView;
  75. /**
  76. * 支持自动转屏,默认NO
  77. */
  78. @property (nonatomic, assign) BOOL shouldAutoRotate;
  79. /**
  80. * jsb changeVideoState 暂停视频后,视频过一秒会继续开始播放.因为 timer 会调用 checkToPlayOrPause.
  81. * 所以用属性进行标记
  82. * 影响范围: 模板/非模板 的激励全屏视频
  83. */
  84. @property (nonatomic, assign) BOOL isJSBPauseVideo;
  85. + (instancetype)playerWithPlayerItem:(BUPlayerItem *)item;
  86. - (void)replaceCurrentItemWithPlayerItem:(BUPlayerItem *)item;
  87. - (void)insertGaosiMohuWithLayer:(CALayer *)layer;
  88. - (void)insertGaosiMohuWithView:(UIView *)view;
  89. /// 设置指定时间回调
  90. /// @param time 时间点
  91. - (void)setPlayerBoundaryTime:(NSInteger)time;
  92. /// 移除播放器定时回调
  93. - (void)removePlayerBoundaryTime;
  94. @end
  95. @interface BUPlayer (BUPlayerControl)
  96. /**
  97. * 播放
  98. */
  99. - (void)play;
  100. /**
  101. * 暂停
  102. */
  103. - (void)pause;
  104. /**
  105. * 重播
  106. */
  107. - (void)replay;
  108. /**
  109. * 停止
  110. */
  111. - (void)stop;
  112. /**
  113. * 跳到指定时间播放
  114. */
  115. - (void)seekToTime:(NSTimeInterval)time completion:(void(^)(BOOL success))completion;
  116. - (void)seekToTime:(NSTimeInterval)time autoPlay:(BOOL)play completion:(void(^)(BOOL success))completion;
  117. /**
  118. * 全屏/竖屏 切换显示
  119. */
  120. - (void)changeOrientationScreen;
  121. /**
  122. * 处于后台模式
  123. */
  124. - (BOOL)isEnterBackground;
  125. /// 显示封面图
  126. /// @param show 是否展示
  127. - (void)showCoverImage:(BOOL)show;
  128. /**
  129. * player是否需要playing
  130. */
  131. - (BOOL)canPlaying;
  132. @end
  133. @interface BUPlayer (BUTrack)
  134. @property (nonatomic, strong) NSString *startTimestamp;
  135. @property (nonatomic, strong) NSString *endTimestamp;
  136. @end