Skip to content

Commit

Permalink
Upgrade SDK and support picture-in-picture
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyanzhang committed Jul 5, 2022
1 parent e89c65c commit b52bf23
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Demo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def common_pods_all
pod 'AFNetworking'
pod 'BlocksKit', '~> 2.2.5'
pod 'CWStatusBarNotification', '~> 2.3.5'
pod 'TXLiteAVSDK_Player', '~> 10.2.11418'
pod 'TXLiteAVSDK_Player', '~> 10.3.11513'
end

def common_pods_smart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ - (void)playVideoWithModel:(FeedVideoModel *)model {

SPDefaultControlView *defaultControlView = (SPDefaultControlView *)self.superPlayView.controlView;
defaultControlView.disableDanmakuBtn = YES;
defaultControlView.disablePipBtn = YES;
}

- (void)pause {
Expand Down
1 change: 1 addition & 0 deletions Demo/TXLiteAVDemo/SuperPlayFeedDemo/Views/FeedDetailView.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

SPDefaultControlView *defaultControlView = (SPDefaultControlView *)self.temPlayView.controlView;
defaultControlView.disableDanmakuBtn = YES;
defaultControlView.disablePipBtn = YES;

// 修改介绍
FeedHeadModel *model = [[FeedHeadModel alloc] init];
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,37 @@
/** 返回按钮*/
@property(nonatomic, strong) UIButton *backBtn;
/// 是否禁用返回
@property(nonatomic) BOOL disableBackBtn;
@property(nonatomic, assign) BOOL disableBackBtn;
/** bottomView*/
@property(nonatomic, strong) UIImageView *bottomImageView;
/** topView */
@property(nonatomic, strong) UIImageView *topImageView;
/** 弹幕按钮 */
@property(nonatomic, strong) UIButton *danmakuBtn;
/// 是否禁用弹幕
@property(nonatomic) BOOL disableDanmakuBtn;
@property(nonatomic, assign) BOOL disableDanmakuBtn;
/** 离线缓存按钮 */
@property(nonatomic, strong) UIButton *offlineBtn;
/// 是否禁用离线缓存
@property(nonatomic) BOOL disableOfflineBtn;
@property(nonatomic, assign) BOOL disableOfflineBtn;
/** 截图按钮 */
@property(nonatomic, strong) UIButton *captureBtn;
/// 是否禁用截图
@property(nonatomic) BOOL disableCaptureBtn;
@property(nonatomic, assign) BOOL disableCaptureBtn;
/** 画中画按钮 */
@property(nonatomic, strong) UIButton *pipBtn;
/// 是否禁用画中画
@property(nonatomic, assign) BOOL disablePipBtn;
/** 更多按钮 */
@property(nonatomic, strong) UIButton *moreBtn;
/// 是否禁用更多
@property(nonatomic) BOOL disableMoreBtn;
@property(nonatomic, assign) BOOL disableMoreBtn;
/** 切换分辨率按钮 */
@property(nonatomic, strong) UIButton *resolutionBtn;
/** 分辨率的View */
@property(nonatomic, strong) UIView *resolutionView;
/// 是否禁用分辨率按钮
@property(nonatomic) BOOL disableResolutionBtn;
@property(nonatomic, assign) BOOL disableResolutionBtn;
/** 播放按钮 */
@property(nonatomic, strong) UIButton *playeBtn;
/** 加载失败按钮 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
[self.topImageView addSubview:self.offlineBtn];
[self.topImageView addSubview:self.moreBtn];
[self addSubview:self.lockBtn];
[self addSubview:self.pipBtn];
[self.topImageView addSubview:self.backBtn];

[self addSubview:self.playeBtn];
Expand All @@ -55,6 +56,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
[self makeSubViewsConstraints];

self.captureBtn.hidden = YES;
self.pipBtn.hidden = YES;
self.danmakuBtn.hidden = YES;
self.offlineBtn.hidden = YES;
self.moreBtn.hidden = YES;
Expand Down Expand Up @@ -176,6 +178,12 @@ - (void)makeSubViewsConstraints {
make.centerY.equalTo(self.mas_centerY);
make.width.height.mas_equalTo(32);
}];

[self.pipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.equalTo(self.mas_trailing).offset(-15);
make.centerY.equalTo(self.mas_centerY);
make.width.height.mas_equalTo(32);
}];

[self.playeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(50);
Expand Down Expand Up @@ -235,6 +243,12 @@ - (void)lockScrrenBtnClick:(UIButton *)sender {
[self fadeOut:3];
}

- (void)pipBtnClick:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(controlViewPip:)]) {
[self.delegate controlViewPip:self];
}
}

- (void)playBtnClick:(UIButton *)sender {
sender.selected = !sender.selected;
if (sender.selected) {
Expand Down Expand Up @@ -271,6 +285,7 @@ - (void)moreBtnClick:(UIButton *)sender {
self.topImageView.hidden = YES;
self.bottomImageView.hidden = YES;
self.lockBtn.hidden = YES;
self.pipBtn.hidden = YES;

self.moreContentView.playerConfig = self.playerConfig;
[self.moreContentView update];
Expand Down Expand Up @@ -303,6 +318,7 @@ - (void)resolutionBtnClick:(UIButton *)sender {
self.topImageView.hidden = YES;
self.bottomImageView.hidden = YES;
self.lockBtn.hidden = YES;
self.pipBtn.hidden = YES;

// 显示隐藏分辨率View
self.resolutionView.hidden = NO;
Expand Down Expand Up @@ -367,6 +383,13 @@ - (void)setDisableCaptureBtn:(BOOL)disableCaptureBtn {
}
}

- (void)setDisablePipBtn:(BOOL)disablePipBtn {
_disablePipBtn = disablePipBtn;
if (self.fullScreen) {
self.pipBtn.hidden = YES;
}
}

- (void)setDisableDanmakuBtn:(BOOL)disableDanmakuBtn {
_disableDanmakuBtn = disableDanmakuBtn;
if (self.fullScreen) {
Expand All @@ -392,6 +415,7 @@ - (void)nextJumpClick:(UIButton *)sender {
- (void)setOrientationLandscapeConstraint {
self.fullScreen = YES;
self.lockBtn.hidden = NO;
self.pipBtn.hidden = YES;
self.fullScreenBtn.selected = self.isLockScreen;
self.fullScreenBtn.hidden = YES;
if (self.disableResolutionBtn) {
Expand Down Expand Up @@ -445,6 +469,7 @@ - (void)setOrientationLandscapeConstraint {
- (void)setOrientationPortraitConstraint {
self.fullScreen = NO;
self.lockBtn.hidden = YES;
self.pipBtn.hidden = self.disablePipBtn;
self.fullScreenBtn.selected = NO;
self.fullScreenBtn.hidden = NO;
self.resolutionBtn.hidden = YES;
Expand Down Expand Up @@ -525,6 +550,15 @@ - (UIButton *)lockBtn {
return _lockBtn;
}

- (UIButton *)pipBtn {
if (!_pipBtn) {
_pipBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_pipBtn setImage:SuperPlayerImage(@"pip_play_icon") forState:UIControlStateNormal];
[_pipBtn addTarget:self action:@selector(pipBtnClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _pipBtn;
}

- (UIButton *)startBtn {
if (!_startBtn) {
_startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
Expand Down Expand Up @@ -707,6 +741,12 @@ - (void)setHidden:(BOOL)hidden {
}

self.lockBtn.hidden = !self.isFullScreen;
if (self.disablePipBtn) {
self.pipBtn.hidden = YES;
} else {
self.pipBtn.hidden = self.isFullScreen;
}

self.isShowSecondView = NO;
self.pointJumpBtn.hidden = YES;
}
Expand All @@ -722,7 +762,12 @@ - (void)playerResetControlView {
self.backgroundColor = [UIColor clearColor];
self.moreBtn.enabled = !self.disableMoreBtn;
self.lockBtn.hidden = !self.isFullScreen;

if (self.disablePipBtn) {
self.pipBtn.hidden = YES;
} else {
self.pipBtn.hidden = self.isFullScreen;
}

self.danmakuBtn.enabled = YES;
self.offlineBtn.enabled = YES;
self.captureBtn.enabled = YES;
Expand Down Expand Up @@ -867,6 +912,16 @@ - (void)setNextBtnState:(BOOL)isShow {
self.nextBtn.hidden = !isShow;
}

- (void)setPipBtnState:(BOOL)isShow {
dispatch_async(dispatch_get_main_queue(), ^{
if (self.fullScreen) {
self.pipBtn.hidden = YES;
} else {
self.pipBtn.hidden = !isShow;
}
});
}

- (void)setOfflineBtnState:(BOOL)isShow {
self.disableOfflineBtn = !isShow;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
*/
- (void)setDisableOfflineBtn:(BOOL)disableOfflineBtn;

/**
* 是否显示画中画控件
* @param isShow YES显示,NO隐藏
*/
- (void)setPipBtnState:(BOOL)isShow;

/**
* 重置播放控制面板
* @param resolutionNames 清晰度名称
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ - (void)setResolutionViewState:(BOOL)isShow {
- (void)setNextBtnState:(BOOL)isShow {
}

- (void)setPipBtnState:(BOOL)isShow {
}

- (void)setDisableOfflineBtn:(BOOL)disableOfflineBtn {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
- (void)controlViewDidChangeScreen:(UIView *)controlView;
/** 锁定屏幕方向 */
- (void)controlViewLockScreen:(UIView *)controlView withLock:(BOOL)islock;
/** 画中画事件 */
- (void)controlViewPip:(UIView *)controlView;
/** 截屏事件 */
- (void)controlViewSnapshot:(UIView *)controlView;
/** 切换分辨率按钮事件 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@
#define VOLUME_CHANGE_KEY (IS_MORE_THAN_15 ? @"Volume" : @"AudioVolume")
#define VOLUME_EXPLICIT_CHANGE @"ExplicitVolumeChange"

#define PIP_START_LOADING_TEXT @"正在开启画中画"
#define PIP_ERROR_LOADING_TEXT @"画中画开启失败了"
#define DEFAULT_PIP_LOADING_WIDTH_MARGIN 20
#define DEFAULT_PIP_LOADING_HEIGHT 50
#define DEFAULT_PIP_LOADING_LABEL_MARGIN 10
#define DEFAULT_PIP_LOADING_LABEL_HEIGHT 40
#define DEFAULT_PIP_LOADING_FONT_SIZE 14

#endif /* SuperPlayerHelpers_h */
Loading

0 comments on commit b52bf23

Please sign in to comment.