BUPlayer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. /**
  16. * 播放内容视图
  17. */
  18. @property (nonatomic, strong, readonly) UIView *view;
  19. /**
  20. * 播放器状态
  21. * 支持KVO
  22. */
  23. @property (nonatomic, assign, readonly) BUVideoPlayerState state;
  24. /// 播放器播放模式改变
  25. @property (nonatomic, assign, readonly) BUVideoPlayerDecoeMode decodeMode;
  26. /**
  27. * 播放资源总时长
  28. */
  29. @property (nonatomic, assign, readonly) NSTimeInterval duration;
  30. /**
  31. * 当前可播放时长
  32. */
  33. @property (nonatomic, assign, readonly) NSTimeInterval playableDuration;
  34. /**
  35. * 实际观看时长
  36. */
  37. @property (nonatomic, assign, readonly) NSTimeInterval watchedDuration;
  38. /**
  39. * 当前播放时间
  40. */
  41. @property (nonatomic, assign, readonly) CGFloat currentPlayTime;
  42. /// 当前播放链接
  43. @property (nonatomic, strong, readonly) NSURL *currentPlayURL;
  44. /**
  45. * 当前播放资源Item
  46. */
  47. @property (nonatomic, strong, readonly) BUPlayerItem *currentPlayerItem;
  48. /**
  49. * 播放器控制层容器,默认视图支持部分定制或完全自定义
  50. * 默认显示控制层全部元素,可以定制部分视图元素显示/隐藏
  51. * 若完全自定义,需先隐藏全部默认视图元素 再在容器上添加自定义视图
  52. */
  53. @property (nonatomic, strong, readonly) UIView<BUPlayerControlViewProtocol> *controlContainer;
  54. /**
  55. * 播放内容视图填充方式
  56. * 默认:等比例填充,直到一个维度到达区域边界
  57. */
  58. @property (nonatomic, assign) BUPlayerLayerGravity playerLayerGravity;
  59. /**
  60. * 播放视图上手势操作选项开关
  61. * 默认全开
  62. */
  63. @property (nonatomic, assign) BUPlayerGestureOption option;
  64. /**
  65. * 静音设置
  66. */
  67. @property (nonatomic, assign) BOOL mute;
  68. /**
  69. * 当前是否全屏显示
  70. */
  71. @property (nonatomic, assign, readonly) BOOL isFullScreen;
  72. /** 设置自定义ControlView */
  73. @property (nonatomic, strong) UIView *controlView;
  74. /**
  75. * 支持自动转屏,默认NO
  76. */
  77. @property (nonatomic, assign) BOOL shouldAutoRotate;
  78. /**
  79. * jsb changeVideoState 暂停视频后,视频过一秒会继续开始播放.因为 timer 会调用 checkToPlayOrPause.
  80. * 所以用属性进行标记
  81. * 影响范围: 模板/非模板 的激励全屏视频
  82. */
  83. @property (nonatomic, assign) BOOL isJSBPauseVideo;
  84. + (instancetype)playerWithPlayerItem:(BUPlayerItem *)item;
  85. - (void)replaceCurrentItemWithPlayerItem:(BUPlayerItem *)item;
  86. @end
  87. @interface BUPlayer (BUPlayerControl)
  88. /**
  89. * 播放
  90. */
  91. - (void)play;
  92. /**
  93. * 暂停
  94. */
  95. - (void)pause;
  96. /**
  97. * 重播
  98. */
  99. - (void)replay;
  100. /**
  101. * 停止
  102. */
  103. - (void)stop;
  104. /**
  105. * 跳到指定时间播放
  106. */
  107. - (void)seekToTime:(NSTimeInterval)time completion:(void(^)(BOOL success))completion;
  108. /**
  109. * 全屏/竖屏 切换显示
  110. */
  111. - (void)changeOrientationScreen;
  112. /**
  113. * 处于后台模式
  114. */
  115. - (BOOL)isEnterBackground;
  116. @end
  117. @interface BUPlayer (BUTrack)
  118. @property (nonatomic, strong) NSString *startTimestamp;
  119. @property (nonatomic, strong) NSString *endTimestamp;
  120. @end