JXSuperPlayer.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // JXSuperPlayer.h
  3. // AICity
  4. //
  5. // Created by TogetherWatch on 2025-10-20.
  6. // Feature: 010-ui-ios - 腾讯云SuperPlayer封装
  7. // 对标Android: JuXingSuperPlayer.kt
  8. //
  9. #import <Foundation/Foundation.h>
  10. #import <UIKit/UIKit.h>
  11. NS_ASSUME_NONNULL_BEGIN
  12. /**
  13. * SuperPlayer播放状态
  14. */
  15. typedef NS_ENUM(NSInteger, JXSuperPlayerState) {
  16. JXSuperPlayerStateIdle, // 空闲
  17. JXSuperPlayerStatePreparing, // 准备中
  18. JXSuperPlayerStatePlaying, // 播放中
  19. JXSuperPlayerStatePaused, // 暂停
  20. JXSuperPlayerStateCompleted, // 播放完成
  21. JXSuperPlayerStateError // 错误
  22. };
  23. /**
  24. * SuperPlayer回调协议
  25. */
  26. @protocol JXSuperPlayerDelegate <NSObject>
  27. @optional
  28. - (void)superPlayerDidChangeState:(JXSuperPlayerState)state;
  29. - (void)superPlayerDidUpdateProgress:(NSTimeInterval)currentTime duration:(NSTimeInterval)duration;
  30. - (void)superPlayerDidFailWithError:(NSError *)error;
  31. @end
  32. /**
  33. * 腾讯云SuperPlayer封装
  34. *
  35. * 功能:
  36. * - 支持FileID+psign播放(DRM)
  37. * - 支持URL播放
  38. * - 自动解析AppID(从psign的JWT中提取)
  39. * - 播放状态管理
  40. * - 生命周期管理
  41. *
  42. * 对标Android: JuXingSuperPlayer.kt
  43. */
  44. @interface JXSuperPlayer : NSObject
  45. @property (nonatomic, weak) id<JXSuperPlayerDelegate> delegate;
  46. @property (nonatomic, strong, readonly) UIView *playerView;
  47. @property (nonatomic, assign, readonly) JXSuperPlayerState state;
  48. /**
  49. * 初始化
  50. * @param containerView 播放器容器视图
  51. */
  52. - (instancetype)initWithContainerView:(UIView *)containerView;
  53. /**
  54. * 播放视频(FileID模式 - DRM推荐)
  55. * @param appId 腾讯云AppID
  56. * @param fileId 腾讯云FileID
  57. * @param psign 播放签名(JWT)
  58. */
  59. - (void)playWithAppId:(NSString *)appId
  60. fileId:(NSString *)fileId
  61. psign:(NSString *)psign;
  62. /**
  63. * 播放视频(URL模式)
  64. * @param url 视频URL
  65. */
  66. - (void)playWithURL:(NSString *)url;
  67. /**
  68. * 播放控制
  69. */
  70. - (void)play;
  71. - (void)pause;
  72. - (void)stop;
  73. - (void)resume;
  74. /**
  75. * 跳转
  76. */
  77. - (void)seekToTime:(NSTimeInterval)time;
  78. /**
  79. * 获取播放信息
  80. */
  81. - (NSTimeInterval)currentTime;
  82. - (NSTimeInterval)duration;
  83. - (BOOL)isPlaying;
  84. /**
  85. * 释放资源
  86. */
  87. - (void)releasePlayer;
  88. /**
  89. * 从psign(JWT)中提取AppID
  90. * @param psign JWT格式的播放签名
  91. * @return AppID字符串,解析失败返回nil
  92. */
  93. + (nullable NSString *)extractAppIdFromPsign:(NSString *)psign;
  94. @end
  95. NS_ASSUME_NONNULL_END