DSPlayerView.h 6.65 KB
//
//  DSPlayerView.h
//  DSCnliveShopSDK
//
//  Created by zhaolin on 2019/6/20.
//  Copyright © 2019 BIKE. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "DSPlayerTopMessageView.h"
#import "DSPlayerBottomMessageView.h"
#import "DSPlayerProgressView.h"
#import "DSPlayerFailureView.h"

UIKIT_EXTERN const float kDSPlayerAnimateTimeInterval;//动画时间

typedef NS_ENUM(NSUInteger, DSPlayerFullScreenType) {           //全屏样式
    DSPlayerFullScreenTypeInCurrentViewOrientation = 0,         //在当前DSPlayView中旋转,用于当前播放界面为全屏样式
    DSPlayerFullScreenTypeInWindowOrientation,                  //在window中旋转,用于小屏不是全屏显示且大屏要全屏显示
    DSPlayerFullScreenTypeFullDisplayOfVideoInterface,          //小屏视频展示为裁剪显示,全屏为全部展示,用于竖屏视频显示全屏属性(暂未开发)
};

NS_ASSUME_NONNULL_BEGIN

@interface DSPlayerView : UIView

#pragma mark - 播放设置

/**
 初始化视频链接地址 为空为停止播放
 */
@property (nonatomic,strong,nullable,readonly) NSURL * playUrl;
/**
 视频链接是否为直播
 */
@property (nonatomic,assign,readonly) BOOL isLive;
/**
 初始化视频

 @param playUrl 视频链接地址 为空为停止播放
 @param isLive 是否为直播
 */
-(void)setPlayUrl:(NSURL * _Nullable)playUrl isLive:(BOOL)isLive;

#pragma mark - 播放属性

/**
 是否循环播放(默认NO)
 */
@property (nonatomic,assign) BOOL isLoopPlay;

/// 开始播放时间
@property (nonatomic,assign) NSTimeInterval startPlayTime;

/// 获取播放时间
-(NSTimeInterval)getPlayTime;

#pragma mark - 播放状态

/**
 开始/继续播放
 */
-(void)play;
/**
 暂停播放
 
 @param isRemove 是否删除kvo、通知、定时器
 */
-(void)pauseWithIsRemoveKVOsAndNotifications:(BOOL)isRemove;
/**
 结束播放 如果isLoopPlay==YES,播放完成时请调用stop方法 否则该类释放不掉
 */
-(void)stop;

#pragma mark - 播放回调

/// 点击返回回调
@property (nonatomic,copy) void (^popCallBack)(void);
/**
 播放器暂停回调
 */
@property (nonatomic,copy) void (^playerPausedCallBack)(DSPlayerView * playerView);
/**
 播放器继续播放回调
 */
@property (nonatomic,copy) void (^playerPlayingCallBack)(DSPlayerView * playerView);
/**
 播放完成回调 如果isLoopPlay==YES,播放完成时请调用stop方法 否则该类释放不掉
 */
@property (nonatomic,copy) void (^playerDidToEndCallBack)(DSPlayerView * playerView);

#pragma mark - 预览界面

/**
 预览界面 (所有的控件都在这个上面)
 */
@property (nonatomic,strong) UIView * previewView;

#pragma mark - 封面图

/**
 封面图(不传封面图就不显示)
 */
@property (nonatomic,strong,nullable) UIImage * coverImage;
/**
 封面图url(先检测封面图,后检测封面图url,不传封面图就不显示)
 */
@property (nonatomic,copy,nullable) NSString * coverImageUrl;
/**
 封面填充属性
 */
@property (nonatomic,assign) UIViewContentMode coverImageViewContentMode;

#pragma mark - 手势

/**
 手势触发view
 */
@property (nonatomic,strong) UIView * gestureView;
/**
 双击手势
 */
@property (nonatomic,strong) UITapGestureRecognizer * gestureViewDoubleTap;
/**
 滑动手势
 */
@property (nonatomic,strong) UIPanGestureRecognizer * gestureViewPanGesture;

#pragma mark - 顶部、底部信息

/**
 顶部信息view
 */
@property (nonatomic,strong) DSPlayerTopMessageView * topMessageView;
/**
 竖屏顶部信息view的高度
 fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 导航高度
 fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 50
 fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时默认 导航高度
 */
@property (nonatomic,assign) CGFloat portraitTopMessageViewHeight;
/**
 横屏顶部信息view的高度
 fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 普通屏 导航高度 iPhoneX系列 20+44
 fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 普通屏 导航高度 iPhoneX系列 20+44
 fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时 不存在横屏 所以此属性无效
 */
@property (nonatomic,assign) CGFloat landscapeTopMessageViewHeight;
/**
 底部信息view
 */
@property (nonatomic,strong) DSPlayerBottomMessageView * bottomMessageView;
/**
 竖屏底部信息view的高度
 fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 普通屏 50 iPhoneX系列 50+底部安全区域
 fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 50
 fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时默认 50
 */
@property (nonatomic,assign) CGFloat portraitBottomMessageViewHeight;
/**
 横屏底部信息view的高度
 fullScreenType == DSPlayerFullScreenTypeInCurrentViewOrientation 时默认 普通屏 50 iPhoneX系列 50+底部安全区域
 fullScreenType == DSPlayerFullScreenTypeInWindowOrientation 时默认 普通屏 50 iPhoneX系列 50+底部安全区域
 fullScreenType == DSPlayerFullScreenTypeFullDisplayOfVideoInterface 时 不存在横屏 所以此属性无效
 */
@property (nonatomic,assign) CGFloat landscapeBottomMessageViewHeight;

/// 底部进度条(当底部信息view隐藏了才会显示)
@property (nonatomic,strong) DSPlayerProgressView * bottomProgressView;

#pragma mark - 失败界面

/**
 失败界面
 */
@property (nonatomic,strong) DSPlayerFailureView * failureView;

#pragma mark - BOOL值

/**
 是否播放完成
 */
@property (nonatomic,assign) BOOL isPlayEnd;
/**
 是否用户手动暂停
 */
@property (nonatomic,assign) BOOL isUserStop;

#pragma mark - 是否锁屏

/**
 是否锁屏
 */
@property (nonatomic,assign) BOOL isLockScreen;
/**
 锁屏/解锁屏回调
 */
@property (nonatomic,copy) void (^switchLockScreenCallBack)(DSPlayerView * playerView);

#pragma mark - 隐藏/显示视频上面的控件

/**
 是否隐藏信息视图
 */
@property (nonatomic,assign) BOOL isAlphaMessage;
/**
 隐藏/显示视频上面的控件回调
 */
@property (nonatomic,copy) void (^switchAlphaMessageStateCallBack)(DSPlayerView * playerView);

#pragma mark - 小屏/全屏

/**
 全屏样式
 */
@property (nonatomic,assign) DSPlayerFullScreenType fullScreenType;
/**
 是否全屏
 */
@property (nonatomic,assign,readonly) BOOL isFullScreen;
/**
 退出全屏
 */
-(void)exitFullScreen;

/**
 是否开启检测设备转屏 默认开启
 */
@property (nonatomic,assign) BOOL isMonitorDeviceOrientation;
/**
 当前屏幕方向
 */
@property (nonatomic,assign) UIInterfaceOrientation currentOrientation;
/**
 修改屏幕方向回调
 */
@property (nonatomic,copy) void (^switchInterfaceOrientationCallBack)(DSPlayerView * playerView);

@end

NS_ASSUME_NONNULL_END