/SJVideoPlayer

Video Player. 视频播放器. 支持调速&提供UI模型, 自由配置UI界面.

Primary LanguageObjective-CMIT LicenseMIT

SJVideoPlayer

installation

pod 'SJVideoPlayer' 

example


play

    Player.asset = [[SJVideoPlayerAssetCarrier alloc] initWithAssetURL:[NSURL URLWithString:@"http://....."] beginTime:10];

play on the table or collection view

    Player.asset =
    [[SJVideoPlayerAssetCarrier alloc] initWithAssetURL:[NSURL URLWithString:cell.model.playURLStr]
                                             scrollView:self.tableView
                                              indexPath:[self.tableView indexPathForCell:cell]
                                           superviewTag:playerParentView.tag];

play on the nested table or collection view

    Player.asset =
    [[SJVideoPlayerAssetCarrier alloc] initWithAssetURL:playURL
                                              indexPath:indexPath
                                           superviewTag:playerParentView.tag
                                    scrollViewIndexPath:embeddedScrollViewIndexPath
                                          scrollViewTag:embeddedScrollView.tag
                                         rootScrollView:self.tableView];

play method

@property (nonatomic, strong, readwrite, nullable) SJVideoPlayerAssetCarrier *asset;

- (void)playWithURL:(NSURL *)playURL jumpedToTime:(NSTimeInterval)time;

@property (nonatomic, strong, readwrite, nullable) NSURL *assetURL;

- (void)playWithURL:(NSURL *)playURL;

- (UIImage *__nullable)screenshot;

- (NSTimeInterval)currentTime;

- (NSTimeInterval)totalTime;

prompt method

@property (nonatomic, strong, readonly) SJPrompt *prompt;

- (void)showTitle:(NSString *)title;

- (void)showTitle:(NSString *)title duration:(NSTimeInterval)duration;

- (void)hiddenTitle;

control method

@property (nonatomic, assign, readonly) BOOL userPaused;

@property (nonatomic, assign, readwrite, getter=isAutoplay) BOOL autoplay;

- (BOOL)play;

- (BOOL)pause;

- (void)stop;

- (void)stopAndFadeOut;

@property (nonatomic, copy, readwrite, nullable) void(^playDidToEnd)(SJVideoPlayer *player);

- (void)jumpedToTime:(NSTimeInterval)time completionHandler:(void (^ __nullable)(BOOL finished))completionHandler;

- (void)seekToTime:(CMTime)time completionHandler:(void (^ __nullable)(BOOL finished))completionHandler;

screen rotation method

@property (nonatomic, assign, readwrite) BOOL disableRotation;

@property (nonatomic, copy, readwrite, nullable) void(^willRotateScreen)(SJVideoPlayer *player, BOOL isFullScreen);

@property (nonatomic, copy, readwrite, nullable) void(^rotatedScreen)(SJVideoPlayer *player, BOOL isFullScreen);

@property (nonatomic, assign, readonly) BOOL isFullScreen;

setting method

- (void)setPlaceholder:(UIImage *)placeholder;

@property (nonatomic, copy, readwrite) void(^clickedBackEvent)(SJVideoPlayer *player);

@property (class, nonatomic, copy, readonly) void(^update)(void(^block)(SJVideoPlayerSettings *commonSettings));

+ (void)resetSetting; // 重置配置, 恢复默认设置

@property (nonatomic, strong, readwrite, nullable) NSArray<SJVideoPlayerMoreSetting *> *moreSettings;

@property (nonatomic, assign, readwrite) BOOL generatePreviewImages;

rate method

@property (nonatomic, assign, readwrite) float rate; /// 0.5 .. 1.5
- (void)resetRate;

@property (nonatomic, copy, readwrite, nullable) void(^rateChanged)(SJVideoPlayer *player);

@property (nonatomic, copy, readwrite, nullable) void(^internallyChangedRate)(SJVideoPlayer *player, float rate);

example


抽离出的组件

  1. 适配 scrollView.
  2. 支持盲区. 指定区域不触发全屏手势. 可指定Frame或者View.
  3. 支持切换. 系统边缘手势与全屏手势随意切换.
  4. 支持禁用手势.

其他组件陆续抽离中...