diff --git a/Demo/Podfile b/Demo/Podfile index 0c68426..8cb62d8 100644 --- a/Demo/Podfile +++ b/Demo/Podfile @@ -27,7 +27,7 @@ def common_pods_all pod 'AFNetworking' pod 'BlocksKit', '~> 2.2.5' pod 'CWStatusBarNotification', '~> 2.3.5' - pod 'TXLiteAVSDK_Player', '~> 11.0.14028' + pod 'TXLiteAVSDK_Player', '~> 11.1.14125' end def common_pods_smart diff --git a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m index c30b055..4324ff7 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m +++ b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/CacheView/VideoCacheListView/VideoCacheListCell.m @@ -270,17 +270,6 @@ - (SuperPlayerModel *)getSuperPlayModel { playModel.videoId = videoId; } - // 获取overlayKey和overlayIv - NSString *overlayStr = [[TXVodDownloadManager shareInstance] getOverlayKeyIv:self.mediaInfo.dataSource.appId - userName:self.mediaInfo.dataSource.userName - fileId:self.mediaInfo.dataSource.fileId - qualityId:(int)self.mediaInfo.dataSource.quality]; - if (overlayStr.length > 0) { - NSArray *overlayArray = [overlayStr componentsSeparatedByString:@"_"]; - playModel.overlayKey = overlayArray.firstObject; - playModel.overlayIv = overlayArray.lastObject; - } - playModel.customCoverImageUrl = _model.coverImageStr; playModel.action = 0; playModel.name = _model.videoName; diff --git a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m index 7b96289..a501cf3 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m +++ b/Demo/TXLiteAVDemo/SuperPlayerDemo/SuperPlayer/MoviePlayerViewController.m @@ -440,28 +440,38 @@ - (void)_refreshVODList { videoArray = [NSMutableArray array]; p = [[TXPlayerAuthParams alloc] init]; - p.appId = 1500005830; - p.fileId = @"243791578431393746"; + p.appId = 1252463788; + p.fileId = @"5285890781763144364"; [videoArray addObject:p]; [_authParamArray addObject:videoArray]; videoArray = [NSMutableArray array]; - TXMoviePlayInfoResponse *trackInfoResponse = [[TXMoviePlayInfoResponse alloc] init]; - trackInfoResponse.name = playerLocalize(@"SuperPlayerDemo.MoviePlayer.multitrackvideo"); - trackInfoResponse.videoUrl = MULTI_TRACK_VIDEO; - trackInfoResponse.isCache = NO; - trackInfoResponse.coverUrl = TRACK_COVERURL; - [videoArray addObject:trackInfoResponse]; + p = [[TXPlayerAuthParams alloc] init]; + p.appId = 1500005830; + p.fileId = @"243791578431393746"; + [videoArray addObject:p]; [_authParamArray addObject:videoArray]; - videoArray = [NSMutableArray array]; - TXMoviePlayInfoResponse *subtitleInfoResponse = [[TXMoviePlayInfoResponse alloc] init]; - subtitleInfoResponse.name = playerLocalize(@"SuperPlayerDemo.MoviePlayer.multisubtitledvideo"); - subtitleInfoResponse.videoUrl = MULTI_SUBTITLES_VIDEO; - subtitleInfoResponse.isCache = NO; - subtitleInfoResponse.coverUrl = SUBTITLES_COVERURL; - [videoArray addObject:subtitleInfoResponse]; - [_authParamArray addObject:videoArray]; + NSDictionary *userDic = [[NSUserDefaults standardUserDefaults] objectForKey:@"vodConfig"]; + if (userDic != nil && userDic.count > 0 && [[userDic objectForKey:@"resources"] intValue] == 1) { + videoArray = [NSMutableArray array]; + TXMoviePlayInfoResponse *trackInfoResponse = [[TXMoviePlayInfoResponse alloc] init]; + trackInfoResponse.name = playerLocalize(@"SuperPlayerDemo.MoviePlayer.multitrackvideo"); + trackInfoResponse.videoUrl = MULTI_TRACK_VIDEO; + trackInfoResponse.isCache = NO; + trackInfoResponse.coverUrl = TRACK_COVERURL; + [videoArray addObject:trackInfoResponse]; + [_authParamArray addObject:videoArray]; + + videoArray = [NSMutableArray array]; + TXMoviePlayInfoResponse *subtitleInfoResponse = [[TXMoviePlayInfoResponse alloc] init]; + subtitleInfoResponse.name = playerLocalize(@"SuperPlayerDemo.MoviePlayer.multisubtitledvideo"); + subtitleInfoResponse.videoUrl = MULTI_SUBTITLES_VIDEO; + subtitleInfoResponse.isCache = NO; + subtitleInfoResponse.coverUrl = SUBTITLES_COVERURL; + [videoArray addObject:subtitleInfoResponse]; + [_authParamArray addObject:videoArray]; + } // 增加轮播视频源 [self loadVideoListData]; @@ -1284,6 +1294,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath if (cell) { if ([[cell getSource].title containsString:playerLocalize(@"SuperPlayerDemo.MoviePlayer.videopreview")]) { [self.playerView showVipTipView]; + defaultControlView.disablePipBtn = YES; } if ([[cell getSource].title containsString:playerLocalize(@"SuperPlayerDemo.MoviePlayer.videoplaylist")]) { diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m index db91619..66b121e 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m @@ -19,6 +19,7 @@ #define MODEL_TAG_BEGIN 20 #define BOTTOM_IMAGE_VIEW_HEIGHT 50 +#define FADEOUTTIME 5 @interface SPDefaultControlView () @@ -71,6 +72,10 @@ - (instancetype)initWithFrame:(CGRect)frame { self.trackView.hidden = YES; self.subtitlesView.hidden = YES; self.nextBtn.hidden = YES; + + UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)]; + longPress.numberOfTouchesRequired = 1; + [self addGestureRecognizer:longPress]; // 初始化时重置controlView [self playerResetControlView]; } @@ -81,6 +86,14 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } +-(void)longPressAction:(UILongPressGestureRecognizer *)longPress{ + if (!self.isFullScreen) { + return; + } + if ([self.delegate respondsToSelector:@selector(onLongPressAction:)]) { + [self.delegate onLongPressAction:longPress]; + } +} - (void)makeSubViewsConstraints { [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.trailing.equalTo(self); @@ -369,9 +382,19 @@ - (void)progressSliderValueChanged:(UISlider *)sender { } - (void)progressSliderTouchEnded:(UISlider *)sender { - [self.delegate controlViewSeek:self where:sender.value]; + [self seekTo:sender.value]; +} + +- (void)onClickProgress:(UITapGestureRecognizer *)gesture{ + CGPoint point = [gesture locationInView:self.videoSlider]; + CGFloat progress = point.x / CGRectGetWidth(self.videoSlider.frame); + [self seekTo:progress]; +} + +- (void)seekTo:(CGFloat)pos{ + [self.delegate controlViewSeek:self where:pos]; self.isDragging = NO; - [self fadeOut:5]; + [self fadeOut:FADEOUTTIME]; } - (void)backLiveClick:(UIButton *)sender { @@ -668,6 +691,9 @@ - (PlayerSlider *)videoSlider { [_videoSlider addTarget:self action:@selector(progressSliderValueChanged:) forControlEvents:UIControlEventValueChanged]; // slider结束滑动事件 [_videoSlider addTarget:self action:@selector(progressSliderTouchEnded:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside]; + // slider点击seek事件 + UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickProgress:)]; + [_videoSlider addGestureRecognizer:tapGesture]; _videoSlider.delegate = self; } return _videoSlider; @@ -873,6 +899,12 @@ - (void)chooseSubtitlesInfo:(TXTrackInfo *)info preSubtitlesInfo:(TXTrackInfo *) } } +- (void)onSettingViewDoneClickWithDic:(NSMutableDictionary *)dic{ + if (self.delegate && [self.delegate respondsToSelector:@selector(onSettingViewDoneClickWithDic:)]) { + [self.delegate onSettingViewDoneClickWithDic:dic]; + } +} + #pragma mark - Public method - (void)setHidden:(BOOL)hidden { diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerControlViewDelegate.h b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerControlViewDelegate.h index d13839f..b80c301 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerControlViewDelegate.h +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerControlViewDelegate.h @@ -30,6 +30,8 @@ - (void)controlViewSwitch:(UIView *)controlView withTrackInfo:(TXTrackInfo *)info preTrackInfo:(TXTrackInfo *)preInfo; /** 切换字幕按钮事件 */ - (void)controlViewSwitch:(UIView *)controlView withSubtitlesInfo:(TXTrackInfo *)info preSubtitlesInfo:(TXTrackInfo *)preInfo; +/** 设置字幕样式按钮事件 */ +- (void)onSettingViewDoneClickWithDic:(NSMutableDictionary *)dic; /** 修改配置 */ - (void)controlViewConfigUpdate:(SuperPlayerControlView *)controlView withReload:(BOOL)reload; /** 重新播放 */ @@ -48,6 +50,8 @@ - (void)onRepeatClick; /** 显示VipView */ - (void)showVipView; +/** 快进/快退按钮*/ +- (void)onLongPressAction:(UILongPressGestureRecognizer *)gesture; @end diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/en.lproj/SuperPlayerLocalized.strings b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/en.lproj/SuperPlayerLocalized.strings index e0a0b9e..9d31dd4 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/en.lproj/SuperPlayerLocalized.strings +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/en.lproj/SuperPlayerLocalized.strings @@ -40,3 +40,5 @@ "SuperPlayer.chooseoutlinecolor" = "Choose Outline Color"; "SuperPlayer.subtitlessetting" = "Subtitles Setting"; "SuperPlayer.track" = "Track"; +"SuperPlayer.fastForward" = "fast forward"; +"SuperPlayer.rewind" = "rewind"; diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/zh-Hans.lproj/SuperPlayerLocalized.strings b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/zh-Hans.lproj/SuperPlayerLocalized.strings index 09c3c44..d812c70 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/zh-Hans.lproj/SuperPlayerLocalized.strings +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerLocalized/zh-Hans.lproj/SuperPlayerLocalized.strings @@ -39,3 +39,5 @@ "SuperPlayer.chooseoutlinecolor" = "选择描边颜色"; "SuperPlayer.subtitlessetting" = "字幕设置"; "SuperPlayer.track" = "音轨"; +"SuperPlayer.fastForward" = "快进"; +"SuperPlayer.rewind" = "快退"; diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m index d3fabd5..3035098 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m @@ -59,6 +59,8 @@ #define CellPlayerFatherViewTag 200 #define SUPPORT_PARAM_MAJOR_VERSION (8) #define SUPPORT_PARAM_MINOR_VERSION (2) +#define PLAY_FORWARD_SPEED_RATE 3 +#define PLAY_BACKWARD_SEEK_TIME 5 //忽略编译器的警告 #pragma clang diagnostic push @@ -68,6 +70,13 @@ @interface SuperPlayerView() @property (nonatomic, strong) UIActivityIndicatorView *pipLoadingView; +@property (nonatomic, strong) dispatch_source_t timer; +@property (nonatomic, strong) UIImageView *playforwardImageView; +@property (nonatomic, strong) UIImageView *playforwardView; +@property (nonatomic, strong) UILabel *playforwardLabel; +@property (nonatomic, strong) UIImageView *playbackwardImageView; +@property (nonatomic, strong) UIImageView *playbackwardView; +@property (nonatomic, strong) UILabel *playbackwardLabel; @end @@ -153,6 +162,7 @@ - (void)initializeThePlayer { __weak __typeof(self) weakSelf = self; SuperPlayerWindowShared.closeHandler = ^{ __strong __typeof(weakSelf) self = weakSelf; + if (!self) { return; } if (self->_watermarkView) { [self->_watermarkView releaseDynamicWater]; [self->_watermarkView removeFromSuperview]; @@ -166,6 +176,8 @@ - (void)initializeThePlayer { [self addNotifications]; // 添加手势 [self createGesture]; + //添加快进快退view + [self setUIView]; self.autoPlay = YES; _hasStartPip = NO; @@ -189,6 +201,11 @@ - (void)dealloc { [_vodPlayer removeVideoWidget]; _vodPlayer = nil; } + + if (_timer) { + dispatch_source_cancel(_timer); + _timer = nil; + } } #pragma mark - 观察者、通知 @@ -215,11 +232,8 @@ - (void)layoutSubviews { [super layoutSubviews]; if (self.subviews.count > 0) { UIView *innerView = self.subviews[0]; - NSString *innerStr = NSStringFromClass([innerView class]); - if ([innerStr isEqualToString:@"TXIJKSDLGLView"] - || [innerStr isEqualToString:@"TXCAVPlayerView"] - || [innerStr isEqualToString:@"TXCThumbPlayerView"]) { - innerView.frame = self.bounds; + if ([innerView isKindOfClass:NSClassFromString(@"TXIJKSDLGLView")] || [innerView isKindOfClass:NSClassFromString(@"TXCAVPlayerView")] || [innerView isKindOfClass:NSClassFromString(@"TXCThumbPlayerView")]) { + innerView.frame = self.bounds; } } } @@ -645,6 +659,14 @@ - (void)setVodPlayConfig { } } + //设置字幕默认样式 + NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; + [dic setObject:@(0xFFFFFFFF) forKey:@"fontColor"]; + [dic setObject:@(0) forKey:@"bondFont"]; + [dic setObject:@(1) forKey:@"outlineWidth"]; + [dic setObject:@(0xFF000000) forKey:@"outlineColor"]; + [self setSubtitleStyle:dic]; + self.vodPlayer.token = self.playerModel.drmToken; self.vodPlayer.enableHWAcceleration = self.playerConfig.hwAcceleration; @@ -816,6 +838,11 @@ - (void)createGesture { self.doubleTap.numberOfTouchesRequired = 1; //手指数 self.doubleTap.numberOfTapsRequired = 2; [self addGestureRecognizer:self.doubleTap]; + + // 长按(快进/快退) + self.longPress =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)]; + self.longPress.numberOfTouchesRequired = 1; //手指数 + [self addGestureRecognizer:self.longPress]; // 解决点击当前view时候响应其他控件事件 [self.singleTap setDelaysTouchesBegan:YES]; @@ -893,7 +920,6 @@ - (void)detailProgress { }; } - self.state = StatePlaying; if (self.state == StatePlaying) { self.centerPlayBtn.hidden = YES; self.repeatBtn.hidden = YES; @@ -1187,6 +1213,70 @@ - (void)doubleTapAction:(UIGestureRecognizer *)gesture { } } +/** + * 长按快进/快退 + * + * @param gesture UITapGestureRecognizer + */ +-(void)longPressAction:(UILongPressGestureRecognizer *)gesture{ + if (!self.isFullScreen) { + return; + } + CGPoint forwardPoint = [gesture locationInView:self.playforwardView]; + BOOL forward = [self.playforwardView.layer containsPoint:forwardPoint]; + CGPoint backwardPoint = [gesture locationInView:self.playbackwardView]; + BOOL backward = [self.playbackwardView.layer containsPoint:backwardPoint]; + if (!(forward || backward)) { + return; + } + if (gesture.state == UIGestureRecognizerStateBegan) { + if (forward) { + [self setPlayforwardHide:NO]; + } + if (backward) { + [self setPlaybackwardHide:NO]; + } + }else if (gesture.state == UIGestureRecognizerStateEnded){ + if (forward) { + [self setPlayforwardHide:YES]; + } + if (backward) { + [self setPlaybackwardHide:YES]; + } + } +} + +/** + 快退 + */ +- (void)setPlaybackwardHide:(BOOL)hide{ + self.playbackwardView.hidden = hide; + self.playbackwardLabel.hidden = hide; + self.playbackwardImageView.hidden = hide; + if (!hide) { + [self setTimer]; + }else{ + if (_timer) { + dispatch_source_cancel(_timer); + _timer = nil; + } + } +} + +/** + 快进 + */ +- (void)setPlayforwardHide:(BOOL)hide{ + self.playforwardView.hidden = hide; + self.playforwardLabel.hidden = hide; + self.playforwardImageView.hidden = hide; + if (!hide) { + [self.vodPlayer setRate:PLAY_FORWARD_SPEED_RATE]; + }else{ + [self.vodPlayer setRate:self.playerConfig.playRate]; + } +} + /** 全屏 */ - (void)setFullScreen:(BOOL)fullScreen { if (fullScreen) { @@ -1372,6 +1462,7 @@ - (void)seekToTime:(NSInteger)dragedSeconds { [self restart]; } else { [self.vodPlayer resume]; + [self.spinner startAnimating]; [self.vodPlayer seek:dragedSeconds]; [self.controlView setPlayState:YES]; } @@ -2075,6 +2166,31 @@ - (void)showVipView { _vodPlayer = nil; } +//配置SPVideoFrameDescription +-(NSArray *)getKeyFrameDescList:(NSArray *)contentList + timeList:(NSArray *)timeList{ + NSMutableArray *keyFrameDescLists = [NSMutableArray new]; + NSInteger min = MIN(contentList.count, timeList.count); + for (int i = 0; i < min; i++) { + SPVideoFrameDescription *frame = [[SPVideoFrameDescription alloc] init]; + frame.text = contentList[i]; + frame.time = [timeList[i] doubleValue]; + [keyFrameDescLists addObject:frame]; + } + return keyFrameDescLists; +} + +-(void)setSubtitleStyle:(NSDictionary *)dic{ + TXPlayerSubtitleRenderModel *model = [[TXPlayerSubtitleRenderModel alloc] init]; + model.canvasWidth = 1920; // 字幕渲染画布的宽 + model.canvasHeight = 1080; // 字幕渲染画布的高 + model.isBondFontStyle = [dic[@"bondFont"] boolValue]; // 设置字幕字体是否为粗体 + model.fontColor = [(NSNumber *)dic[@"fontColor"] unsignedIntValue]; // 设置字幕字体颜色,默认白色 + model.outlineWidth = [(NSNumber *)dic[@"outlineWidth"] floatValue]; //描边宽度 + model.outlineColor = [(NSNumber *)dic[@"outlineColor"] unsignedIntValue]; //描边颜色 + [self.vodPlayer setSubtitleStyle:model]; +} + - (void)controlViewSwitch:(UIView *)controlView withTrackInfo:(TXTrackInfo *)info preTrackInfo:(TXTrackInfo *)preInfo { if (info.trackIndex == -1) { [self.vodPlayer deselectTrack:preInfo.trackIndex]; @@ -2103,6 +2219,33 @@ - (void)controlViewSwitch:(UIView *)controlView withSubtitlesInfo:(TXTrackInfo * [self.controlView fadeOut:1]; } +- (void)onSettingViewDoneClickWithDic:(NSMutableDictionary *)dic{ + [self setSubtitleStyle:dic]; +} + +- (void)onLongPressAction:(UILongPressGestureRecognizer *)gesture{ + [self longPressAction:gesture]; +} + +- (void)setTimer{ + if (!_timer) { + dispatch_queue_t queue = dispatch_get_main_queue(); + _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); + dispatch_source_set_timer(_timer, DISPATCH_TIME_NOW, NSEC_PER_SEC, 0.0 * NSEC_PER_SEC); + } + //快退5秒,播放1秒 + __weak __typeof(self)weakSelf = self; + dispatch_source_set_event_handler(_timer, ^{ + __strong typeof(self) strongSelf = weakSelf; + float seekTime = strongSelf.playCurrentTime - PLAY_BACKWARD_SEEK_TIME; + if (seekTime < 0 ) { + seekTime = 0; + } + [self.vodPlayer seek:seekTime]; + }); + dispatch_resume(_timer); +} + #pragma clang diagnostic pop #pragma mark - 点播回调 @@ -2185,6 +2328,10 @@ - (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.keyFrameDescList = [self getKeyFrameDescList: + [param objectForKey:VOD_PLAY_EVENT_KEY_FRAME_CONTENT_LIST] + timeList:[param objectForKey:VOD_PLAY_EVENT_KEY_FRAME_TIME_LIST]]; + self.controlView.pointArray = self.keyFrameDescList; self->_currentVideoUrl = [param objectForKey:VOD_PLAY_EVENT_PLAY_URL]; NSString *imageSpriteVtt = [param objectForKey:VOD_PLAY_EVENT_IMAGESPRIT_WEBVTTURL]?:@""; NSArray *imageSpriteList = [param objectForKey:VOD_PLAY_EVENT_IMAGESPRIT_IMAGEURL_LIST]; @@ -2534,6 +2681,115 @@ - (UIButton *)repeatBtn { return _repeatBtn; } +- (void)setUIView{ + + [self addSubview:self.playforwardView]; + [_playforwardView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(180); + make.top.equalTo(self.mas_top); + make.bottom.equalTo(self.mas_bottom); + make.trailing.equalTo(self.mas_trailing); + }]; + + [self addSubview:self.playforwardImageView]; + [_playforwardImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.equalTo(_playforwardView.mas_leading).offset(70); + make.centerY.equalTo(self.mas_centerY); + make.width.height.mas_equalTo(40); + }]; + + [self addSubview:self.playforwardLabel]; + [_playforwardLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(_playforwardImageView.mas_bottom).offset(5); + make.centerX.equalTo(_playforwardImageView.mas_centerX); + make.width.mas_equalTo(70); + make.height.mas_equalTo(40); + }]; + + [self addSubview:self.playbackwardView]; + [_playbackwardView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.equalTo(self.mas_leading); + make.top.equalTo(self.mas_top); + make.bottom.equalTo(self.mas_bottom); + make.width.mas_equalTo(180); + }]; + + [self addSubview:self.playbackwardImageView]; + [_playbackwardImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.equalTo(self.mas_leading).offset(70); + make.centerY.equalTo(self.mas_centerY); + make.width.height.mas_equalTo(40); + }]; + + [self addSubview:self.playbackwardLabel]; + [_playbackwardLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(_playbackwardImageView.mas_bottom).offset(5); + make.centerX.equalTo(_playbackwardImageView.mas_centerX); + make.width.mas_equalTo(70); + make.height.mas_equalTo(40); + }]; +} + +- (UIImageView *)playforwardImageView{ + if (!_playforwardImageView) { + UIImage *image = SuperPlayerImage(@"playforward"); + _playforwardImageView = [[UIImageView alloc] init]; + [_playforwardImageView setImage:image]; + _playforwardImageView.hidden = YES; + } + return _playforwardImageView; +} + +- (UILabel *)playforwardLabel{ + if (!_playforwardLabel) { + _playforwardLabel = [[UILabel alloc] init]; + _playforwardLabel.font = [UIFont systemFontOfSize:16]; + _playforwardLabel.textColor = [UIColor whiteColor]; + _playforwardLabel.textAlignment = NSTextAlignmentCenter; + _playforwardLabel.text = superPlayerLocalized(@"SuperPlayer.fastForward"); + _playforwardLabel.hidden = YES; + } + return _playforwardLabel; +} +- (UIImageView *)playforwardView{ + if (!_playforwardView) { + UIImage *image = SuperPlayerImage(@"playforward_bg"); + _playforwardView = [[UIImageView alloc] init]; + [_playforwardView setImage:image]; + _playforwardView.hidden = YES; + } + return _playforwardView; +} +- (UIImageView *)playbackwardImageView{ + if (!_playbackwardImageView) { + UIImage *image = SuperPlayerImage(@"playbackward"); + _playbackwardImageView = [[UIImageView alloc] init]; + [_playbackwardImageView setImage:image]; + _playbackwardImageView.hidden = YES; + } + return _playbackwardImageView; +} +- (UILabel *)playbackwardLabel{ + if (!_playbackwardLabel) { + _playbackwardLabel = [[UILabel alloc] init]; + _playbackwardLabel.font = [UIFont systemFontOfSize:16]; + _playbackwardLabel.textColor = [UIColor whiteColor]; + _playbackwardLabel.textAlignment = NSTextAlignmentCenter; + _playbackwardLabel.text = superPlayerLocalized(@"SuperPlayer.rewind"); + _playbackwardLabel.hidden = YES; + } + return _playbackwardLabel; +} +- (UIImageView *)playbackwardView{ + if (!_playbackwardView) { + UIImage *image = SuperPlayerImage(@"playbackward_bg"); + _playbackwardView = [[UIImageView alloc] init]; + [_playbackwardView setImage:image]; + _playbackwardView.hidden = YES; + } + return _playbackwardView; +} + - (UIButton *)repeatBackBtn { if (!_repeatBackBtn) { _repeatBackBtn = [UIButton buttonWithType:UIButtonTypeCustom]; diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SubtitlesSettingView/SuperPlayerSubSettingView.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SubtitlesSettingView/SuperPlayerSubSettingView.m index ffb85b6..185f192 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SubtitlesSettingView/SuperPlayerSubSettingView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SubtitlesSettingView/SuperPlayerSubSettingView.m @@ -121,7 +121,7 @@ - (void)initSubtitlesSettingView { NSArray *fontColorArr = [weakSelf fontColorArray]; SuperPlayerTableMenu *menu = [SuperPlayerTableMenu title:superPlayerLocalized(@"SuperPlayer.choosefontcolor") array:fontColorArr]; [menu clickCellWithResultblock:^(NSInteger index) { - weakSelf.fontColorType = index + 1; + weakSelf.fontColorType = index; [weakSelf.fontColorBtn setChooseTitle:fontColorArr[index] name:[weakSelf stringFontColor]]; }]; }]; @@ -130,7 +130,7 @@ - (void)initSubtitlesSettingView { NSArray *bondFontArr = [weakSelf bondFontArray]; SuperPlayerTableMenu *menu = [SuperPlayerTableMenu title:superPlayerLocalized(@"SuperPlayer.choosebontfont") array:bondFontArr]; [menu clickCellWithResultblock:^(NSInteger index) { - weakSelf.fontColorType = index + 1; + weakSelf.bondFontType = index; [weakSelf.bondFontBtn setChooseTitle:bondFontArr[index] name:[weakSelf stringBondFont]]; }]; }]; @@ -139,7 +139,7 @@ - (void)initSubtitlesSettingView { NSArray *outlineWidthArr = [weakSelf outlineWidthArray]; SuperPlayerTableMenu *menu = [SuperPlayerTableMenu title:superPlayerLocalized(@"SuperPlayer.chooseoutlinewidth") array:outlineWidthArr]; [menu clickCellWithResultblock:^(NSInteger index) { - weakSelf.fontColorType = index + 1; + weakSelf.outlineWidthType = index; [weakSelf.outlineWidthBtn setChooseTitle:outlineWidthArr[index] name:[weakSelf stringOutLineWidth]]; }]; }]; @@ -148,7 +148,7 @@ - (void)initSubtitlesSettingView { NSArray *outlineColorArr = [weakSelf outlineColorArray]; SuperPlayerTableMenu *menu = [SuperPlayerTableMenu title:superPlayerLocalized(@"SuperPlayer.chooseoutlinecolor") array:outlineColorArr]; [menu clickCellWithResultblock:^(NSInteger index) { - weakSelf.fontColorType = index + 1; + weakSelf.outlineColorType = index; [weakSelf.outlineColorBtn setChooseTitle:outlineColorArr[index] name:[weakSelf stringOutlineColor]]; }]; }]; @@ -177,7 +177,7 @@ - (void)setDefaultBtnStatus { self.outlineColorType = [[dic objectForKey:@"outlineColor"] integerValue]; NSArray *outlineColorArray = [self outlineColorArray]; - [self.outlineColorBtn setChooseTitle:outlineColorArray[self.outlineColorType] name:[self stringFontColor]]; + [self.outlineColorBtn setChooseTitle:outlineColorArray[self.outlineColorType] name:[self stringOutlineColor]]; } - (NSArray *)fontColorArray { @@ -185,20 +185,43 @@ - (NSArray *)fontColorArray { @"Green", @"Yellow" ,@"Magenta", @"Cyan"]; } +- (uint32_t)getFontColor:(NSInteger)index { + NSArray *array = @[@(0xFFFFFFFF), @(0xFF000000), @(0xFFFF0000), @(0xFF0000FF), + @(0xFF00FF00), @(0xFFFFFF00), @(0xFFFF00FF), @(0xFF00FFFF)]; + return [array[index] unsignedIntValue]; +} + - (NSArray *)bondFontArray { return @[@"Normal(默认)",@"BoldFace"]; } +- (BOOL)getBondFont:(NSInteger)index{ + NSArray *array = @[@(0),@(1)]; + return [array[index] boolValue]; +} + - (NSArray *)outlineWidthArray { return @[@"50%", @"75%", @"100%(默认)" ,@"125%", @"150%", @"175%" ,@"200%", @"300%", @"400%"]; } +- (CGFloat)getOutlineWidth:(NSInteger)index{ + NSArray *array = @[@(0.5), @(0.75), @(1) ,@(1.25), + @(1.5), @(1.75) ,@(2), @(3), @(4)]; + return [array[index] floatValue]; +} + - (NSArray *)outlineColorArray { return @[@"Black(默认)", @"White", @"Red" ,@"Blue", @"Green", @"Yellow" ,@"Magenta", @"Cyan"]; } +- (uint32_t)getOutlineColor:(NSInteger)index { + NSArray *array = @[@(0xFF000000), @(0xFFFFFFFF), @(0xFFFF0000), @(0xFF0000FF), + @(0xFF00FF00), @(0xFFFFFF00), @(0xFFFF00FF), @(0xFF00FFFF)]; + return [array[index] unsignedIntValue]; +} + - (NSString *)stringFontColor { return @"Font Color:"; } @@ -237,10 +260,11 @@ - (void)backBtnClick { - (void)doneBtnClick { NSMutableDictionary *mDic = [[NSMutableDictionary alloc] init]; - [mDic setObject:@(self.fontColorType) forKey:@"fontColor"]; - [mDic setObject:@(self.bondFontType) forKey:@"bondFont"]; - [mDic setObject:@(self.outlineWidthType) forKey:@"outlineWidth"]; - [mDic setObject:@(self.outlineColorType) forKey:@"outlineColor"]; + + [mDic setObject:@([self getFontColor:self.fontColorType]) forKey:@"fontColor"]; + [mDic setObject:@([self getBondFont:self.bondFontType]) forKey:@"bondFont"]; + [mDic setObject:@([self getOutlineWidth:self.outlineWidthType]) forKey:@"outlineWidth"]; + [mDic setObject:@([self getOutlineColor:self.outlineColorType]) forKey:@"outlineColor"]; [[NSUserDefaults standardUserDefaults] setObject:mDic forKey:@"subtitlesConfig"]; [[NSUserDefaults standardUserDefaults] synchronize]; diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.h b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.h index b9c1be6..f821b69 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.h +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.h @@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)chooseSubtitlesInfo:(TXTrackInfo *)info preSubtitlesInfo:(TXTrackInfo *)preInfo; +- (void)onSettingViewDoneClickWithDic:(NSMutableDictionary *)dic; + @end @interface SuperPlayerSubtitlesView : UIView diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.m index 7942119..660d005 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerSubtitlesView/SuperPlayerSubtitlesView.m @@ -125,7 +125,10 @@ - (void)onSettingViewBackClick { } - (void)onSettingViewDoneClickWithDic:(NSMutableDictionary *)dic { - // todo:回调给SuperPlayerView调用SDK设置字幕样式 + // 回调给SuperPlayerView调用SDK设置字幕样式 + if (self.delegate && [self.delegate respondsToSelector:@selector(onSettingViewDoneClickWithDic:)]) { + [self.delegate onSettingViewDoneClickWithDic:dic]; + } } #pragma mark - 懒加载 diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerView+Private.h b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerView+Private.h index 1a7206e..e1d6850 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerView+Private.h +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Views/SuperPlayerView+Private.h @@ -51,6 +51,8 @@ typedef NS_ENUM(NSInteger, ButtonAction) { @property(nonatomic, assign) BOOL didEnterBackground; /** 单击 */ @property(nonatomic, strong) UITapGestureRecognizer *singleTap; +/** 长按 */ +@property(nonatomic, strong) UILongPressGestureRecognizer *longPress; /** 双击 */ @property(nonatomic, strong) UITapGestureRecognizer *doubleTap; /** 快进快退、View*/