Skip to content

Commit

Permalink
1、Upgrade SDK version to enhance user experience
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyanzhang committed Jul 7, 2023
1 parent 58d1ead commit c65ffce
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 315 deletions.
2 changes: 1 addition & 1 deletion Demo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def common_pods_all
pod 'AFNetworking'
pod 'BlocksKit', '~> 2.2.5'
pod 'CWStatusBarNotification', '~> 2.3.5'
pod 'TXLiteAVSDK_Player', '~> 11.2.14217'
pod 'TXLiteAVSDK_Player', '~> 11.3.14327'
end

def common_pods_smart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,15 @@ - (void)setPlayerView:(SuperPlayerView *)playerView {
}

///SuperPlayerDelegate
-(void)superPlayerFullScreenChanged:(SuperPlayerView *)player {
if (player.isFullScreen) {
player.disableGesture = YES;
[player showOrHideBackBtn:YES];
} else {
player.disableGesture = NO;
[player showOrHideBackBtn:NO];
}
}
-(void)backHookAction{

[self.navigationController popViewControllerAnimated:NO];
Expand Down
7 changes: 7 additions & 0 deletions Demo/TXLiteAVDemo/SuperPlayFeedDemo/Utils/FeedRequestUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ + (void)getPlayInfo:(int)appId
code:-1
userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"parameter error"]}];
completion(nil, error);
return;
}
}

Expand All @@ -50,6 +51,7 @@ + (void)getPlayInfo:(int)appId
if (error) {
if (completion) {
completion(nil, error);
return;
}
}

Expand All @@ -59,6 +61,7 @@ + (void)getPlayInfo:(int)appId
code:-1
userInfo:@{NSLocalizedDescriptionKey : @"request error", NSLocalizedFailureReasonErrorKey : @"content is nil"}];
completion(nil, error);
return;
}
}

Expand All @@ -71,6 +74,7 @@ + (void)getPlayInfo:(int)appId
code:-2
userInfo:@{NSLocalizedDescriptionKey : @"invalid format"}];
completion(nil, error);
return;
}
}

Expand All @@ -81,6 +85,7 @@ + (void)getPlayInfo:(int)appId
code:code
userInfo:@{NSLocalizedDescriptionKey : dict[@"message"]}];
completion(nil, error);
return;
}
}

Expand All @@ -103,6 +108,7 @@ + (void)getPlayInfo:(int)appId

if (completion) {
completion(dic, nil);
return;
}

} @catch (NSException *exception) {
Expand All @@ -111,6 +117,7 @@ + (void)getPlayInfo:(int)appId
code:-2
userInfo:@{NSLocalizedDescriptionKey : @"invalid format"}];
completion(nil, error);
return;
}
}
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef NS_ENUM(NSUInteger, FeedCellStyle) {
/**
全屏
*/
- (void)showFullScreenViewWithPlayView:(SuperPlayerView *)superPlayerView cell:(FeedTableViewCell *)cell;
- (void)showFullScreenViewWithPlayView:(SuperPlayerView *)superPlayerView indexPath:(NSIndexPath *)indexPath;
///屏幕旋转
- (void)screenRotation:(BOOL)fullScreen;
@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ - (void)superPlayerDidStart {
}
}
-(void)showFullScreenViewWithPlayView:(SuperPlayerView *)superPlayerView {
if (self.delegate && [self.delegate respondsToSelector:@selector(showFullScreenViewWithPlayView:cell:)]){
[self.delegate showFullScreenViewWithPlayView:superPlayerView cell:self];
if (self.delegate && [self.delegate respondsToSelector:@selector(showFullScreenViewWithPlayView:indexPath:)]){
[self.delegate showFullScreenViewWithPlayView:superPlayerView indexPath:self.indexPath];
}
}
- (void)screenRotation:(BOOL)fullScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, weak) id<FeedBaseViewDelegate> delegate;

@property (nonatomic, strong) SuperPlayerView *superPlayView;
@property (nonatomic, strong, nullable) SuperPlayerView *superPlayView;

@property (nonatomic, strong) FeedHeadView *headView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ - (instancetype)init {
if (self = [super init]) {
self.backgroundColor = [UIColor colorWithRed:14.0/255.0 green:24.0/255.0 blue:47.0/255.0 alpha:1.0];
[self addSubview:self.fatherView];
[self.fatherView addSubview:self.superPlayView];
self.superPlayView = [self createSuperPlayView];
self.superPlayView.fatherView = self.fatherView;
[self addSubview:self.headView];
[self addSubview:self.marginView];

Expand Down Expand Up @@ -78,6 +79,14 @@ - (void)setModel:(FeedVideoModel *)model {
headModel.videoSubTitleStr = model.videoIntroduce;

[self.headView setHeadModel:headModel];

if (self.superPlayView == nil ) { ///如果为nil 说明这个视频窗口被移动到了横屏VC或者详情VC
///tableview发生了reload导致不再是原来的cell
self.superPlayView = [self createSuperPlayView]; ///
self.superPlayView.fatherView = self.fatherView;
}


[self.superPlayView.controlView setTitle:model.title];
[self playVideoWithModel:model];
}
Expand All @@ -98,7 +107,11 @@ - (void)playVideoWithModel:(FeedVideoModel *)model {
playerModel.multiVideoURLs = model.multiVideoURLs;
self.playerModel = playerModel;
[self.superPlayView.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.coverUrl] placeholderImage:SuperPlayerImage(@"defaultCoverImage")];
self.superPlayView.centerPlayBtn.hidden = NO;
if (self.superPlayView.state == StatePlaying) {
self.superPlayView.centerPlayBtn.hidden = YES;
} else {
self.superPlayView.centerPlayBtn.hidden = NO;
}
self.superPlayView.controlView.hidden = YES;
[self.superPlayView showOrHideBackBtn:NO];
SPDefaultControlView *defaultControlView = (SPDefaultControlView *)self.superPlayView.controlView;
Expand Down Expand Up @@ -131,9 +144,10 @@ - (void)resetPlayer {
}

- (void)addSuperPlayView:(UIView *)view {
[self.superPlayView pause];
[self.superPlayView removeFromSuperview];
self.superPlayView = (SuperPlayerView *)view;
self.superPlayView.delegate = self;
[self addSubview:self.superPlayView];
self.superPlayView.fatherView = self.fatherView;
[self.superPlayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(8);
Expand All @@ -142,6 +156,12 @@ - (void)addSuperPlayView:(UIView *)view {
make.height.mas_equalTo(cellHeight);
}];

if (self.superPlayView.state == StatePlaying) {
self.superPlayView.centerPlayBtn.hidden = YES;
} else {
self.superPlayView.centerPlayBtn.hidden = NO;
}


}

Expand Down Expand Up @@ -179,6 +199,7 @@ - (void)screenRotation:(BOOL)fullScreen {
-(void)fullScreenHookAction {
if (self.delegate && [self.delegate respondsToSelector:@selector(showFullScreenViewWithPlayView:)]){
[self.delegate showFullScreenViewWithPlayView:self.superPlayView];
self.superPlayView = nil;
}
}
#pragma mark - 懒加载
Expand All @@ -197,16 +218,15 @@ - (UIView *)marginView {
return _marginView;
}

- (SuperPlayerView *)superPlayView {
if (!_superPlayView) {
_superPlayView = [SuperPlayerView new];
_superPlayView.fatherView = self.fatherView;
_superPlayView.backgroundColor = [UIColor clearColor];
_superPlayView.disableGesture = NO;
_superPlayView.delegate = self;
_superPlayView.disableVolumControl = YES;
}
return _superPlayView;

- (SuperPlayerView *)createSuperPlayView {
SuperPlayerView *superPlayView = [SuperPlayerView new];
superPlayView.fatherView = self.fatherView;
superPlayView.backgroundColor = [UIColor clearColor];
superPlayView.disableGesture = NO;
superPlayView.delegate = self;
superPlayView.disableVolumControl = YES;
return superPlayView;
}

- (FeedHeadView *)headView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
/**
显示详情页的处理
*/
- (void)showFeedDetailViewWithHeadModel:(FeedHeadModel *)model videoModel:(FeedVideoModel *)videoModel playView:(SuperPlayerView *)superPlayView;
- (void)showFeedDetailViewWithHeadModel:(FeedHeadModel *)model
videoModel:(FeedVideoModel *)videoModel
playView:(SuperPlayerView *)superPlayView;
/**
全屏
*/
Expand Down
31 changes: 21 additions & 10 deletions Demo/TXLiteAVDemo/SuperPlayFeedDemo/Views/SuperFeedPlayView.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ @interface SuperFeedPlayView()<UITableViewDelegate, UITableViewDataSource, UIScr
@property (nonatomic, assign) NSInteger currentPlayIndex;

@property (nonatomic, assign) BOOL isRefresh;

@property (nonatomic, strong) NSIndexPath *indexPath; ///横屏的cell
@end

@implementation SuperFeedPlayView
Expand Down Expand Up @@ -81,11 +83,12 @@ - (void)finishLoadMore {
}

- (void)addSuperPlayView:(UIView *)view {
FeedTableViewCell *cell = [self.tableView cellForRowAtIndexPath:self.indexPath];
if ([NSThread isMainThread]) {
[self.tapTableViewCell addSuperPlayView:view];
[cell addSuperPlayView:view];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self.tapTableViewCell addSuperPlayView:view];
[cell addSuperPlayView:view];
});
}
}
Expand Down Expand Up @@ -147,7 +150,9 @@ - (void)playVideoFromCell:(FeedTableViewCell *)cell {
for (UITableViewCell *cell in cells) {
if (cell != self.currentTableViewCell) {
FeedTableViewCell *cel = (FeedTableViewCell *)cell;
[cel pause];
if (cel.baseView.superPlayView.state == StatePlaying) {
[cel pause];
}
}
}
}
Expand Down Expand Up @@ -269,9 +274,11 @@ - (void)headViewClickWithCell:(FeedTableViewCell *)cell {
[self.currentTableViewCell pause];
}
self.tapTableViewCell = cell;
[cell.baseView.superPlayView removeFromSuperview];

[self.delegate showFeedDetailViewWithHeadModel:headModel videoModel:cell.model playView:cell.baseView.superPlayView];
self.indexPath = cell.indexPath;
[self.delegate showFeedDetailViewWithHeadModel:headModel
videoModel:cell.model
playView:cell.baseView.superPlayView];
cell.baseView.superPlayView = nil;
}
}

Expand All @@ -287,18 +294,21 @@ - (void)superPlayerDidStartWithCell:(FeedTableViewCell *)cell {
for (UITableViewCell *cell in cells) {
if (cell != self.currentTableViewCell) {
FeedTableViewCell *cel = (FeedTableViewCell *)cell;
[cel pause];
if (cel.baseView.superPlayView.state == StatePlaying) {
[cel pause];
}
}
}
}

-(void)showFullScreenViewWithPlayView:(SuperPlayerView *)superPlayerView cell:(nonnull FeedTableViewCell *)cell{
-(void)showFullScreenViewWithPlayView:(SuperPlayerView *)superPlayerView
indexPath:(NSIndexPath *)indexPath{
self.indexPath = indexPath;
FeedTableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (self.delegate && [self.delegate respondsToSelector:@selector(showFullScreenViewWithPlayView:)]){
if (cell != self.currentTableViewCell) {
[self.currentTableViewCell pause];
}
self.tapTableViewCell = cell;
[cell.baseView.superPlayView removeFromSuperview];
[self.delegate showFullScreenViewWithPlayView:superPlayerView];
}
}
Expand Down Expand Up @@ -339,6 +349,7 @@ - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell
if (self.currentTableViewCell == cell) {
self.currentTableViewCell = nil;
}
[(FeedTableViewCell *)cell pause];
}

// 松手时已经静止,只会调用scrollViewDidEndDragging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2022年 Tencent. All rights reserved.

#import <Foundation/Foundation.h>
#import "TXVodDownloadManager.h"
@class TXVodDownloadMediaInfo;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2022年 Tencent. All rights reserved.

#import <Foundation/Foundation.h>
#import "TXPlayerDrmBuilder.h"
@class TXPlayerDrmBuilder;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2022年 Tencent. All rights reserved.

#import <UIKit/UIKit.h>
#import "SuperPlayerModel.h"
@class SuperPlayerModel;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <Foundation/Foundation.h>
#import "DownloadCallback.h"
#import "TXPlayerDrmBuilder.h"
@class TXPlayerDrmBuilder;

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ - (void)onScanResult:(NSString *)result {
m.title = [NSString stringWithFormat:@"%@%lu", LivePlayerLocalize(@"SuperPlayerDemo.MoviePlayer.video"), (unsigned long)_liveDataSourceArray.count + 1];
[_liveDataSourceArray addObject:m];
[_liveListView reloadData];
[self clickLiveList:self.liveBtn];
} else {
if (model.videoId) {
[m setModel:model];
Expand All @@ -1200,6 +1201,7 @@ - (void)onScanResult:(NSString *)result {
[videoArray addObject:m];
[_vodDataSourceArray addObject:videoArray];
[_vodListView reloadData];
[self clickVodList:self.vodBtn];
}
self.playerView.isLockScreen = NO;
}
Expand Down
Loading

0 comments on commit c65ffce

Please sign in to comment.