Skip to content

Commit

Permalink
1. Upgrade Demo to optimize functional experience
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyanzhang committed Nov 30, 2022
1 parent a37a919 commit d155d2d
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 87 deletions.
4 changes: 3 additions & 1 deletion Demo/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Uncomment the next line to define a global platform for your project

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

def tx_im
Expand All @@ -25,7 +27,7 @@ def common_pods_all
pod 'AFNetworking'
pod 'BlocksKit', '~> 2.2.5'
pod 'CWStatusBarNotification', '~> 2.3.5'
pod 'TXLiteAVSDK_Player', '~> 10.7.11934'
pod 'TXLiteAVSDK_Player', '~> 10.8.12025'
end

def common_pods_smart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ - (void)stopDownload {

- (SuperPlayerModel *)getSuperPlayModel {
SuperPlayerModel *playModel = [[SuperPlayerModel alloc] init];



if (self.mediaInfo.playPath.length > 0 && self.mediaInfo.downloadState == 4) {
if (self.mediaInfo.playPath.length > 0 && self.mediaInfo.downloadState == TXVodDownloadMediaInfoStateFinish) {
SuperPlayerUrl *playerUrl = [[SuperPlayerUrl alloc] init];
[gQualityDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
if ([obj integerValue] == self.mediaInfo.dataSource.quality) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,12 +1319,16 @@ - (void)clickVodList:(id)sender {
[self.vodBtn setSelected:YES];
[self.liveBtn setSelected:NO];
[self.scrollView scrollRectToVisible:CGRectMake(0, 0, ScreenWidth, self.scrollView.mm_h) animated:YES];
[self showControlView:YES];
[self.playerView.controlView setEnableFadeAction:YES];
}

- (void)clickLiveList:(id)sender {
[self.vodBtn setSelected:NO];
[self.liveBtn setSelected:YES];
[self.scrollView scrollRectToVisible:CGRectMake(ScreenWidth, 0, ScreenWidth, self.scrollView.mm_h) animated:YES];
[self showControlView:NO];
[self.playerView.controlView setEnableFadeAction:NO];
}

#pragma mark - 弹幕
Expand Down
128 changes: 95 additions & 33 deletions Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,46 @@
#import "SuperPlayerSettingsView.h"
#import "SuperPlayerViewConfig.h"

@interface SuperPlayerControlView : UIView
@interface SuperPlayerControlView : UIView

/**
* 竖向/横向约束标志位
*/
@property(assign, nonatomic) BOOL compact;
/**
* 点播放试看时间范围 0.0 - 1.0
*
* 用于试看场景,防止进度条拖动超过试看时长
*/
@property(assign, nonatomic) float maxPlayableRatio;
/**
* 标题
*/
@property (nonatomic, copy) NSString *title;
/**
* 打点信息
*/
@property (nonatomic, strong) NSArray<SPVideoFrameDescription *> *pointArray;
/**
* 是否在拖动进度
*/
@property (nonatomic, assign) BOOL isDragging;
/**
* 是否显示二级菜单
*/
@property (nonatomic, assign) BOOL isShowSecondView;
/**
* 是否允许控件响应点击的 FadeShow/ FadeOut事件,默认为YES
*/
@property (nonatomic, assign) BOOL enableFadeAction;
/**
* 回调delegate
*/
@property (nonatomic, weak) id<SuperPlayerControlViewDelegate> delegate;
/**
* 播放配置
*/
@property (nonatomic, strong) SuperPlayerViewConfig *playerConfig;
/**
* 播放进度
* @param currentTime 当前播放时长
Expand Down Expand Up @@ -88,20 +120,14 @@
isTimeShifting:(BOOL)isTimeShifting
isPlaying:(BOOL)isPlaying;

/// 标题
@property NSString *title;
/// 打点信息
@property NSArray<SPVideoFrameDescription *> *pointArray;
/// 是否在拖动进度
@property BOOL isDragging;
/// 是否显示二级菜单
@property BOOL isShowSecondView;
/// 回调delegate
@property(nonatomic, weak) id<SuperPlayerControlViewDelegate> delegate;
/// 播放配置
@property SuperPlayerViewConfig *playerConfig;

/**
* 设置竖直方向的约束
*/
- (void)setOrientationPortraitConstraint;

/**
* 设置横屏方向的约束
*/
- (void)setOrientationLandscapeConstraint;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_compact = YES;
_enableFadeAction = YES;
}
return self;
}
Expand Down
36 changes: 18 additions & 18 deletions Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,27 @@ typedef NS_ENUM(NSInteger, SuperPlayerLayoutStyle) {
/// 是否锁定旋转
@property(nonatomic, assign) BOOL isLockScreen;
/// 是否是直播流
@property(readonly) BOOL isLive;
@property(nonatomic, assign, readonly) BOOL isLive;
/// 是否自动播放(在playWithModel前设置)
@property BOOL autoPlay;
@property(nonatomic, assign) BOOL autoPlay;
/// 超级播放器控制层
@property(nonatomic) SuperPlayerControlView *controlView;
@property(nonatomic, strong) SuperPlayerControlView *controlView;
/// 是否允许竖屏手势
@property(nonatomic) BOOL disableGesture;
@property(nonatomic, assign) BOOL disableGesture;
/// 是否在手势中
@property(readonly) BOOL isDragging;
@property(nonatomic, assign, readonly) BOOL isDragging;
/// 是否加载成功
@property(readonly) BOOL isLoaded;
@property(nonatomic, assign, readonly) BOOL isLoaded;
/// 是否允许音量按钮控制,默认是不允许
@property(nonatomic, assign) BOOL disableVolumControl;
/// 封面图片
@property(nonatomic) UIImageView *coverImageView;
@property(nonatomic, strong) UIImageView *coverImageView;
/// 设置vipTipView
@property(nonatomic) TXVipTipView *vipTipView;
@property(nonatomic, strong) TXVipTipView *vipTipView;
/// 设置vipWatchView
@property(nonatomic) TXVipWatchView *vipWatchView;
@property(nonatomic, strong) TXVipWatchView *vipWatchView;
/// 设置vip试看的model
@property(nonatomic) TXVipWatchModel *vipWatchModel;
@property(nonatomic, strong) TXVipWatchModel *vipWatchModel;
/// 设置vip试看的model
@property(nonatomic, assign) BOOL isCanShowVipTipView;
/// 重播按钮
Expand All @@ -123,25 +123,25 @@ typedef NS_ENUM(NSInteger, SuperPlayerLayoutStyle) {
/// 全屏退出
@property(nonatomic, strong) UIButton *repeatBackBtn;
/// 视频总时长
@property(nonatomic) CGFloat playDuration;
@property(nonatomic, assign) CGFloat playDuration;
/// 视频当前播放时间
@property(nonatomic) CGFloat playCurrentTime;
@property(nonatomic, assign) CGFloat playCurrentTime;
/// 起始播放时间,用于从上次位置开播
@property CGFloat startTime;
@property(nonatomic, assign) CGFloat startTime;
/// 播放的视频Model
@property(readonly) SuperPlayerModel *playerModel;
@property(nonatomic, strong, readonly) SuperPlayerModel *playerModel;
/// 播放器配置
@property SuperPlayerViewConfig *playerConfig;
@property(nonatomic, strong) SuperPlayerViewConfig *playerConfig;
/// 循环播放
@property(nonatomic) BOOL loop;
@property(nonatomic, assign) BOOL loop;
/**
* 视频雪碧图
*/
@property TXImageSprite *imageSprite;
@property(nonatomic, strong) TXImageSprite *imageSprite;
/**
* 打点信息
*/
@property NSArray<SPVideoFrameDescription *> *keyFrameDescList;
@property(nonatomic, strong) NSArray<SPVideoFrameDescription *> *keyFrameDescList;
/**
* 播放model
* 注意:10.7版本开始,需要通过{@link TXLiveBase#setLicence} 设置 Licence后方可成功播放, 否则将播放失败(黑屏),全局仅设置一次即可。
Expand Down
71 changes: 54 additions & 17 deletions Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,13 @@ - (void)resume {
[self.controlView setPlayState:YES];
self.isPauseByUser = NO;
self.centerPlayBtn.hidden = YES;
[self.controlView setSliderState:YES];
[self.controlView setTopViewState:YES];
if (_playerModel.action == PLAY_ACTION_MANUAL_PLAY) {
[self showOrHideBackBtn:YES];

if (self.controlView.enableFadeAction) {
[self.controlView setSliderState:YES];
[self.controlView setTopViewState:YES];
if (_playerModel.action == PLAY_ACTION_MANUAL_PLAY) {
[self showOrHideBackBtn:YES];
}
}

if (self.isLive) {
Expand Down Expand Up @@ -371,7 +374,9 @@ - (void)pause {
if (!self.isLoaded) return;
if (self.playDidEnd) return;
self.repeatBtn.hidden = YES;
[[self.controlView fadeShow] fadeOut:1];
if (self.controlView.enableFadeAction) {
[[self.controlView fadeShow] fadeOut:1];
}
[self.controlView setPlayState:NO];
self.isPauseByUser = YES;
self.state = StatePause;
Expand Down Expand Up @@ -545,11 +550,6 @@ - (void)configTXPlayer {
[self.livePlayer stopPlay];
[self.vodPlayer removeVideoWidget];
[self.livePlayer removeVideoWidget];

if (_hasStartPip) {
[self.vodPlayer exitPictureInPicture];
}

_hasStartPip = NO;
_vodPlayer = nil;

Expand Down Expand Up @@ -687,7 +687,9 @@ - (void)preparePlayVideo {
[self.controlView setPlayState:YES];
[self.controlView setSliderState:YES];
} else {
[self.controlView fadeOut:0.2];
if (self.controlView.enableFadeAction) {
[self.controlView fadeOut:0.2];
}
}
self.isPauseByUser = NO;
self.centerPlayBtn.hidden = YES;
Expand Down Expand Up @@ -906,6 +908,23 @@ - (void)prepareAutoplay {
}
}

- (NSArray<NSURL *> *)convertImageSpriteList:(NSArray<NSString *> *)imageSpriteList
{
if (!imageSpriteList) {
return nil;
}

NSMutableArray<NSURL *> *imageSpriteURLs = [NSMutableArray array];
for (NSString *imageSpriteStr in imageSpriteList) {
NSURL *imageSpriteURL = [NSURL URLWithString:imageSpriteStr];
if (imageSpriteURL) {
[imageSpriteURLs addObject:imageSpriteURL];
}
}

return [imageSpriteURLs copy];
}

#pragma mark - KVO

/**
Expand Down Expand Up @@ -1076,10 +1095,12 @@ - (void)singleTapAction:(UIGestureRecognizer *)gesture {
[self.delegate singleTapClick];
}

if (self.controlView.hidden) {
[[self.controlView fadeShow] fadeOut:5];
} else {
[self.controlView fadeOut:0.2];
if (self.controlView.enableFadeAction) {
if (self.controlView.hidden) {
[[self.controlView fadeShow] fadeOut:5];
} else {
[self.controlView fadeOut:0.2];
}
}

if (self.isFullScreen) {
Expand All @@ -1097,7 +1118,9 @@ - (void)singleTapAction:(UIGestureRecognizer *)gesture {
*/
- (void)doubleTapAction:(UIGestureRecognizer *)gesture {
// 显示控制层
[self.controlView fadeShow];
if (self.controlView.enableFadeAction) {
[self.controlView fadeShow];
}

if (self.playDidEnd) {
[self.vodPlayer stopPlay];
Expand Down Expand Up @@ -1653,6 +1676,16 @@ - (CGFloat)playCurrentTime {
+ (UISlider *)volumeViewSlider {
return _volumeSlider;
}

- (TXImageSprite *)imageSprite
{
if (!_imageSprite) {
_imageSprite = [[TXImageSprite alloc] init];
}

return _imageSprite;
}

#pragma mark - SuperPlayerControlViewDelegate

- (void)controlViewPlay:(SuperPlayerControlView *)controlView {
Expand Down Expand Up @@ -2063,7 +2096,11 @@ - (void)onPlayEvent:(TXVodPlayer *)player event:(int)EvtID withParam:(NSDictiona
self.videoRatio = (GLfloat)player.width / player.height;
}
} else if (EvtID == PLAY_EVT_GET_PLAYINFO_SUCC) {
self->_currentVideoUrl = [param objectForKey:@"EVT_PLAY_URL"];
self->_currentVideoUrl = [param objectForKey:VOD_PLAY_EVENT_PLAY_URL];
NSString *imageSpriteVtt = [param objectForKey:VOD_PLAY_EVENT_IMAGESPRIT_WEBVTTURL]?:@"";
NSArray<NSString *> *imageSpriteList = [param objectForKey:VOD_PLAY_EVENT_IMAGESPRIT_IMAGEURL_LIST];
NSArray<NSURL *> *imageURLs = [self convertImageSpriteList:imageSpriteList];
[self.imageSprite setVTTUrl:[NSURL URLWithString:imageSpriteVtt] imageUrls:imageURLs];
}

[self onVodPlayEvent:player event:EvtID withParam:param];
Expand Down

0 comments on commit d155d2d

Please sign in to comment.