CSJVideoAdTracker.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // BUVideoAdReportorTracker.h
  3. // CSJAdSDK
  4. //
  5. // Created by bytedance on 2021/1/27.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "CSJVideoAdReportor.h"
  9. #import "CSJAdSlot.h"
  10. #import "CSJMaterialMeta+Private.h"
  11. NS_ASSUME_NONNULL_BEGIN
  12. // 从外部获取 tag 值
  13. typedef NSString * _Nullable (^VideoTagBlock)(void);
  14. // 从外部获取当前播放时间
  15. typedef NSUInteger (^VideoPlayTimeBlock) (void);
  16. typedef CSJMaterialMeta * _Nullable (^VideoAdMetaBlock) (void);
  17. @class CSJMaterialMeta;
  18. /// 视频性能追踪,兼容旧版本
  19. @interface CSJVideoAdTracker : NSObject
  20. /// 视频播放类型
  21. @property(nonatomic, assign, readonly) BUPlayerPlayType video_play_type;
  22. /// 视频播放 URL
  23. @property(nonatomic, copy, readonly) NSString *video_play_url;
  24. /// 视频分辨率
  25. @property(nonatomic, copy, readonly) NSString *video_resolution;
  26. /// 视频大小,单位
  27. @property(nonatomic, assign, readonly) NSUInteger video_size;
  28. /// 视频总时长,单位 ms
  29. @property(nonatomic, assign, readonly) NSUInteger video_duration;
  30. @property (nonatomic, assign) NSUInteger holdPlayerCount;
  31. - (instancetype)init NS_UNAVAILABLE;
  32. - (instancetype)initWithVideoTagBlock:(VideoTagBlock)tagBlock playTimeBlock:(VideoPlayTimeBlock)timeBlock metaBlock:(VideoAdMetaBlock)metaBlock;
  33. /// 配置上报数据,当播放器初始化之后 & 播放器触发降级之后,视频上报工具内部数据,默认为内部播放器
  34. /// @param decodeMode 当前解码模式
  35. /// @param h265VideoInfo H265 视频数据
  36. /// @param h264VideoInfo H264 视频数据
  37. - (void)configVideoInfoWithDecodeMode:(BUVideoPlayerDecoeMode)decodeMode
  38. h265VideoInfo:(nullable CSJVideoInfo *)h265VideoInfo
  39. h264VideoInfo:(nullable CSJVideoInfo *)h264VideoInfo;
  40. /// 配置上报数据,当播放器初始化之后 & 播放器触发降级之后,视频上报工具内部数据。
  41. /// @param decodeMode 当前解码模式
  42. /// @param h265VideoInfo H265 视频数据
  43. /// @param h264VideoInfo H264 视频数据
  44. /// @param customPlayer 是否是自定义播放器
  45. - (void)configVideoInfoWithDecodeMode:(BUVideoPlayerDecoeMode)decodeMode
  46. h265VideoInfo:(nullable CSJVideoInfo *)h265VideoInfo
  47. h264VideoInfo:(nullable CSJVideoInfo *)h264VideoInfo
  48. customPlayer:(BOOL)customPlayer;
  49. /// 滑动重置
  50. - (void)reportVideoReset;
  51. #pragma mark - 播放打点
  52. /// 播放
  53. - (void)reportVideoStartPlay;
  54. /// 首帧
  55. - (void)reportVideoFirstRender:(BOOL)autoPlay;
  56. /// 暂停
  57. - (void)reportVideoPause;
  58. /// 继续播放
  59. - (void)reportVideoResume;
  60. /// 重新播放
  61. - (void)reportVideoReplay;
  62. - (void)reportVideoAutoReplay;
  63. /// 播放错误
  64. /// @param error 播放错误
  65. - (void)reportVideoError:(NSError *)error;
  66. #pragma mark - End Card
  67. /// 非正常调用 EndCard
  68. /// @param reason EndCard 原因
  69. /// @param hasPlayed 是有有过播放行为
  70. - (void)reportVideoEndCard:(BUEncardSkipType)reason hasPlayed:(BOOL)hasPlayed;
  71. #pragma mark - 播放结束打点
  72. /// 非正常播放结束上报
  73. /// @param playerBreakType 非正常结束原因
  74. - (void)reportVideoWithPlayerBreakType:(BUPlayerBreakType)playerBreakType;
  75. /// 播放完成
  76. - (void)reportVideoPlayOver;
  77. /// 开始缓冲
  78. - (void)recordBeginBuffer;
  79. /// 结束缓冲
  80. - (void)recordEndBuffer;
  81. @end
  82. NS_ASSUME_NONNULL_END