Skip to content

Commit

Permalink
1、Upgrade Demo to optimize the experience of Picture-in-Picture
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyanzhang committed Sep 29, 2022
1 parent d83844f commit bea33e0
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 29 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.7.11918'
pod 'TXLiteAVSDK_Player', '~> 10.7.11934'
end

def common_pods_smart
Expand Down
81 changes: 64 additions & 17 deletions Demo/TXLiteAVDemo/App/TXConfigManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
// Copyright © 2021 Tencent. All rights reserved.
//

#ifdef ENTERPRISE
#import <BuglyOA/Bugly.h>
#import <BuglyOA/BuglyConfig.h>
#endif
#import <Bugly/Bugly.h>
#import <Bugly/BuglyConfig.h>

#ifdef LIVE
#import "V2TXLivePremier.h"
Expand All @@ -19,12 +17,19 @@

#ifdef ENABLE_UGC
#import "TXUGCBase.h"
#import "TELicenseCheck.h"
#endif

#ifdef ENABLE_TRTC
#import "TRTCCloud.h"
#endif

#if defined(TRTC) || defined(PROFESSIONAL)
#import <ToolKitBase/ToolKitBase.h>
#import <TRTCKit/TRTCKit.h>
#import "ProfileManager.h"
#endif

#import "AppLocalized.h"
#import "AppLogMgr.h"
#import "TCUtil.h"
Expand All @@ -38,6 +43,7 @@ @interface TXConfigManager ()

@property(nonatomic, strong) NSDictionary *config;
@property(nonatomic, weak) id actionTarget;
@property(nonatomic, strong) NSMutableArray *routeArray;

@end

Expand All @@ -47,6 +53,7 @@ + (instancetype)shareInstance {
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
_shareInstance = [[TXConfigManager alloc] init];
_shareInstance.routeArray = [NSMutableArray arrayWithCapacity:2];
});
return _shareInstance;
}
Expand Down Expand Up @@ -89,6 +96,10 @@ - (void)loadConfig {
plistName = @"Smart";
#endif

#ifdef WECHATTOOLS
plistName = @"WeChatTools";
#endif

NSString *filePath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
_config = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
}
Expand Down Expand Up @@ -135,14 +146,25 @@ - (void)setLicence {
//添加UGC模块的
#ifdef ENABLE_UGC
[TXUGCBase setLicenceURL:licenceUrl key:licenceKey];
[TELicenseCheck setTELicense:licenceUrl key:licenceKey completion:^(NSInteger authresult, NSString * _Nonnull errorMsg) {
if (authresult == TELicenseCheckOk) {
NSLog(@"鉴权成功");
} else {
NSLog(@"鉴权失败");
}
}];
#endif
#if !defined(UGC)
#ifdef LIVE
[V2TXLivePremier setLicence:licenceUrl key:licenceKey];
#else

#ifdef ENABLE_PLAY
[TXLiveBase setLicenceURL:licenceUrl key:licenceKey];
#endif

#endif

#if defined(PLAYER)
NSString *licenceUrl = [self.licenceConfig objectForKey:@"licenceUrl"];
NSString *licenceKey = [self.licenceConfig objectForKey:@"licenceKey"];
[TXLiveBase setLicenceURL:licenceUrl key:licenceKey];
#endif
}

Expand Down Expand Up @@ -182,18 +204,24 @@ - (void)initDebug {
}
}
- (void)setupBugly {
if (![self isRelease]) {
return;
}

#if defined(ENTERPRISE) && !defined(DEBUG)
// 启动bugly组件,bugly组件为腾讯提供的用于crash上报和分析的开放组件,如果您不需要该组件,可以自行移除
BuglyConfig *config = [[BuglyConfig alloc] init];
config.version = [TXAppInfo appVersionWithBuild];
config.channel = @"LiteAV Release";
[Bugly startWithAppId:BUGLY_APP_ID config:config];
NSLog(@"rtmp demo init crash report");
if ([self isRelease]) {
// Release版本Channel设置
config.channel = @"LiteAV Release";
} else {
#ifdef TRTC_EMBED
config.channel = @"LiteAV TRTC_Refactoring"; // 重构打包Chanel设置
#else
config.channel = @"LiteAV Debug"; // 其他模式,内部测试用
#endif
}
#ifdef DEBUG
config.debugMode = YES;
#endif
config.version = [TXAppInfo appVersionWithBuild];
[Bugly startWithAppId:BUGLY_APP_ID config:config];

}

- (NSMutableArray<CellInfo *> *)getMenuConfig {
Expand All @@ -213,6 +241,7 @@ - (void)setupBugly {
for (NSDictionary *subMenu in subMenus) {
NSString *subTitle = [subMenu objectForKey:@"title"];
NSString *classStr = [subMenu objectForKey:@"class"];
NSString *routeName = [subMenu objectForKey:@"route"];
bool debug = [subMenu objectForKey:@"debug"];
if (debug && ![TCUtil getDEBUGSwitch]) {
continue;
Expand All @@ -226,6 +255,24 @@ - (void)setupBugly {
CellInfo *subCellInfo = [CellInfo cellInfoWithTitle:subTitle
controllerClassName:classStr];
[subCells addObject:subCellInfo];
#if defined(TRTC) || defined(PROFESSIONAL)
} else if (routeName.length > 0) {
TKBaseRouter *route = [[NSClassFromString(routeName) alloc] initWithNavigation:self.navigation];
if (isTrtc) {
NSString *userID = [ProfileManager shared].curUserID;
TRTCUserInfo *userInfo = [[TRTCUserInfo alloc] initWithUserId:userID];
route = [[NSClassFromString(routeName) alloc] initWithNavigation:self.navigation userInfo:userInfo];
}
[self.routeArray addObject:route];
NSArray *entrances = [route entrances];
[entrances enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
TKMainEntrance *entrance = obj;
CellInfo *subCellInfo = [CellInfo cellInfoWithTitle:entrance.title actionBlock:^{
entrance.action();
}];
[subCells addObject:subCellInfo];
}];
#endif
} else {
__weak __typeof(self) weakSelf = self;
CellInfo *subCellInfo =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ - (void)onCenterDownloadError:(TXVodDownloadMediaInfo *)mediaInfo errorCode:(NSI
for (VideoCacheModel *model in self.videoArray) {
if ((model.appId == mediaInfo.dataSource.appId) && ([model.fileId isEqualToString:mediaInfo.dataSource.fileId])) {
toastName = model.videoTitle;
model.isCache = NO;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ - (void)onDownloadFinish:(TXVodDownloadMediaInfo *)mediaInfo {
}
/// 下载错误
- (void)onDownloadError:(TXVodDownloadMediaInfo *)mediaInfo errorCode:(TXDownloadError)code errorMsg:(NSString *)msg {
if (self.delegate && [self.delegate respondsToSelector:@selector(onDownloadError:errorCode:errorMsg:)]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(onCenterDownloadError:errorCode:errorMsg:)]) {
[self.delegate onCenterDownloadError:mediaInfo errorCode:code errorMsg:msg];
}

Expand Down
27 changes: 17 additions & 10 deletions Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceive
- (void)setState:(SuperPlayerState)state {
_state = state;
// 控制菊花显示、隐藏
if (state == StateBuffering) {
if (state == StateBuffering && !_playDidEnd) {
[self.spinner startAnimating];
} else {
[self.spinner stopAnimating];
Expand Down Expand Up @@ -2257,15 +2257,22 @@ - (void)onPlayer:(TXVodPlayer *)player pictureInPictureStateDidChange:(TX_VOD_PL
self->_restoreUI = NO;
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self pause];
[player stopPlay];
[player removeVideoWidget];
[self.vodPlayer stopPlay];
[self.vodPlayer removeVideoWidget];
self.vodPlayer = nil;
self.state = StateStopped;
});
if (!self.didEnterBackground) {
if (_playDidEnd || isShowVipWatchView) {
dispatch_async(dispatch_get_main_queue(), ^{
[self pause];
[player stopPlay];
[player removeVideoWidget];
[self.vodPlayer stopPlay];
[self.vodPlayer removeVideoWidget];
self.vodPlayer = nil;
self.state = StateStopped;
[self.spinner stopAnimating];
});
} else {
[player exitPictureInPicture];
}
}
}
}
}
Expand Down

0 comments on commit bea33e0

Please sign in to comment.