| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // JXSuperPlayer.h
- // AICity
- //
- // Created by TogetherWatch on 2025-10-20.
- // Feature: 010-ui-ios - 腾讯云SuperPlayer封装
- // 对标Android: JuXingSuperPlayer.kt
- //
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
- NS_ASSUME_NONNULL_BEGIN
- /**
- * SuperPlayer播放状态
- */
- typedef NS_ENUM(NSInteger, JXSuperPlayerState) {
- JXSuperPlayerStateIdle, // 空闲
- JXSuperPlayerStatePreparing, // 准备中
- JXSuperPlayerStatePlaying, // 播放中
- JXSuperPlayerStatePaused, // 暂停
- JXSuperPlayerStateCompleted, // 播放完成
- JXSuperPlayerStateError // 错误
- };
- /**
- * SuperPlayer回调协议
- */
- @protocol JXSuperPlayerDelegate <NSObject>
- @optional
- - (void)superPlayerDidChangeState:(JXSuperPlayerState)state;
- - (void)superPlayerDidUpdateProgress:(NSTimeInterval)currentTime duration:(NSTimeInterval)duration;
- - (void)superPlayerDidFailWithError:(NSError *)error;
- @end
- /**
- * 腾讯云SuperPlayer封装
- *
- * 功能:
- * - 支持FileID+psign播放(DRM)
- * - 支持URL播放
- * - 自动解析AppID(从psign的JWT中提取)
- * - 播放状态管理
- * - 生命周期管理
- *
- * 对标Android: JuXingSuperPlayer.kt
- */
- @interface JXSuperPlayer : NSObject
- @property (nonatomic, weak) id<JXSuperPlayerDelegate> delegate;
- @property (nonatomic, strong, readonly) UIView *playerView;
- @property (nonatomic, assign, readonly) JXSuperPlayerState state;
- /**
- * 初始化
- * @param containerView 播放器容器视图
- */
- - (instancetype)initWithContainerView:(UIView *)containerView;
- /**
- * 播放视频(FileID模式 - DRM推荐)
- * @param appId 腾讯云AppID
- * @param fileId 腾讯云FileID
- * @param psign 播放签名(JWT)
- */
- - (void)playWithAppId:(NSString *)appId
- fileId:(NSString *)fileId
- psign:(NSString *)psign;
- /**
- * 播放视频(URL模式)
- * @param url 视频URL
- */
- - (void)playWithURL:(NSString *)url;
- /**
- * 播放控制
- */
- - (void)play;
- - (void)pause;
- - (void)stop;
- - (void)resume;
- /**
- * 跳转
- */
- - (void)seekToTime:(NSTimeInterval)time;
- /**
- * 获取播放信息
- */
- - (NSTimeInterval)currentTime;
- - (NSTimeInterval)duration;
- - (BOOL)isPlaying;
- /**
- * 释放资源
- */
- - (void)releasePlayer;
- /**
- * 从psign(JWT)中提取AppID
- * @param psign JWT格式的播放签名
- * @return AppID字符串,解析失败返回nil
- */
- + (nullable NSString *)extractAppIdFromPsign:(NSString *)psign;
- @end
- NS_ASSUME_NONNULL_END
|