From 23ffb31d1499381067e1cf9e86d8228ac49543fa Mon Sep 17 00:00:00 2001 From: zhiruiou Date: Sat, 2 Apr 2022 20:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E6=92=AD=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/Podfile | 1 + Demo/Podfile.lock | 54 ++++++++-------- Demo/TXLiteAVDemo.xcodeproj/project.pbxproj | 13 ---- .../xcschemes/TXLiteAVDemo_Player.xcscheme | 20 +----- .../Controller/FeedDetailViewController.m | 2 +- .../Views/FeedBaseView/FeedBaseView.m | 3 + .../SuperPlayFeedDemo/Views/FeedDetailView.m | 9 +++ .../Views/SuperFeedPlayView.m | 7 +++ .../SuperPlayer/MoviePlayerViewController.m | 16 +++-- .../SuperPlayerKit/SuperPlayer.podspec | 20 ------ .../SuperPlayer/Skins/SPDefaultControlView.m | 2 +- .../SuperPlayer/SuperPlayerView.h | 33 ++++++++++ .../SuperPlayer/SuperPlayerView.m | 63 +++++++++++++++++-- .../SuperPlayer_Flutter.podspec | 55 ++++++++++++++++ .../Tools/TXVideoPlayer/TXVideoPlayer.m | 3 +- .../View/SuperShortVideoView.m | 28 +-------- .../View/TXBaseView/TXVideoBaseView.h | 3 + .../View/TXBaseView/TXVideoBaseView.m | 18 +++++- README.md | 2 - SDK/README.md | 8 --- 20 files changed, 230 insertions(+), 130 deletions(-) create mode 100644 Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer_Flutter.podspec delete mode 100644 SDK/README.md diff --git a/Demo/Podfile b/Demo/Podfile index 9c91d38e..792e5381 100644 --- a/Demo/Podfile +++ b/Demo/Podfile @@ -25,6 +25,7 @@ def common_pods_all pod 'AFNetworking' pod 'BlocksKit', '~> 2.2.5' pod 'CWStatusBarNotification', '~> 2.3.5' + pod 'TXLiteAVSDK_Player' end def common_pods_smart diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock index f0e9cdd8..6df44a86 100644 --- a/Demo/Podfile.lock +++ b/Demo/Podfile.lock @@ -1,18 +1,18 @@ PODS: - - AFNetworking (4.0.0): - - AFNetworking/NSURLSession (= 4.0.0) - - AFNetworking/Reachability (= 4.0.0) - - AFNetworking/Security (= 4.0.0) - - AFNetworking/Serialization (= 4.0.0) - - AFNetworking/UIKit (= 4.0.0) - - AFNetworking/NSURLSession (4.0.0): + - AFNetworking (4.0.1): + - AFNetworking/NSURLSession (= 4.0.1) + - AFNetworking/Reachability (= 4.0.1) + - AFNetworking/Security (= 4.0.1) + - AFNetworking/Serialization (= 4.0.1) + - AFNetworking/UIKit (= 4.0.1) + - AFNetworking/NSURLSession (4.0.1): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/Reachability (4.0.0) - - AFNetworking/Security (4.0.0) - - AFNetworking/Serialization (4.0.0) - - AFNetworking/UIKit (4.0.0): + - AFNetworking/Reachability (4.0.1) + - AFNetworking/Security (4.0.1) + - AFNetworking/Serialization (4.0.1) + - AFNetworking/UIKit (4.0.1): - AFNetworking/NSURLSession - BlocksKit (2.2.5): - BlocksKit/All (= 2.2.5) @@ -29,19 +29,20 @@ PODS: - BlocksKit/UIKit (2.2.5): - BlocksKit/Core - BlocksKit/DynamicDelegate - - Bugly (2.5.2) + - Bugly (2.5.91) - CWStatusBarNotification (2.3.5) - Masonry (1.1.0) - MBProgressHUD (1.2.0) - - MJExtension (3.2.1) - - MJRefresh (3.3.1) - - SDWebImage (5.6.1): - - SDWebImage/Core (= 5.6.1) - - SDWebImage/Core (5.6.1) + - MJExtension (3.4.1) + - MJRefresh (3.7.5) + - SDWebImage (5.12.5): + - SDWebImage/Core (= 5.12.5) + - SDWebImage/Core (5.12.5) - SuperPlayer/Player (3.1.1): - AFNetworking - Masonry - SDWebImage + - TXLiteAVSDK_Player (9.5.29016) DEPENDENCIES: - AFNetworking @@ -54,6 +55,7 @@ DEPENDENCIES: - MJRefresh - SDWebImage - SuperPlayer/Player (from `./TXLiteAVDemo/SuperPlayerKit/SuperPlayer.podspec`) + - TXLiteAVSDK_Player SPEC REPOS: trunk: @@ -66,23 +68,25 @@ SPEC REPOS: - MJExtension - MJRefresh - SDWebImage + - TXLiteAVSDK_Player EXTERNAL SOURCES: SuperPlayer: :path: "./TXLiteAVDemo/SuperPlayerKit/SuperPlayer.podspec" SPEC CHECKSUMS: - AFNetworking: d9fdf484a3c723ec3c558a41cc5754c7e845ee77 + AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce BlocksKit: 7f422b971407001178d181a43b99014ea2591fe6 - Bugly: dbac48b55ad469a97cc4321045cd50df8f63d44f + Bugly: afe841bba2ea6de6d432a3c125240a5e75949c55 CWStatusBarNotification: 3d2738b25c3207f60cc50201388d3c96182545ff Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 - MJExtension: 635f2c663dcb1bf76fa4b715b2570a5710aec545 - MJRefresh: eeda70fbf0ad277f3178cef1cd0c3532591d6237 - SDWebImage: 7edb9c3ea661e77a66661f7f044de8c1b55d1120 - SuperPlayer: 3f49af712410a59c42c2c9bfcacd33e3a0e3e5ab + MJExtension: 21c5f6f8c4d5d8844b7ae8fbae08fed0b501f961 + MJRefresh: fdf5e979eb406a0341468932d1dfc8b7f9fce961 + SDWebImage: 0905f1b7760fc8ac4198cae0036600d67478751e + SuperPlayer: a0ee257eba416cf238160613186f5f1008acb4c5 + TXLiteAVSDK_Player: 5a9cea3ba4e77fc8993b19523afbecdfc1a803ce -PODFILE CHECKSUM: 1df379d334d15387f79476735627426f004b5aed +PODFILE CHECKSUM: df3ee50302b30473bf7bce4ab300599d5f976278 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 diff --git a/Demo/TXLiteAVDemo.xcodeproj/project.pbxproj b/Demo/TXLiteAVDemo.xcodeproj/project.pbxproj index 7349f688..c2c6bb16 100644 --- a/Demo/TXLiteAVDemo.xcodeproj/project.pbxproj +++ b/Demo/TXLiteAVDemo.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ 400923631F4FCC6E009B882D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 40F853221EE8FC7300EE47D7 /* Assets.xcassets */; }; 4009238F1F4FCC6E009B882D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 40F853331EE8FC9B00EE47D7 /* Main.storyboard */; }; 402A010424506F740037A219 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 402A010024506F740037A219 /* main.m */; }; - 4071CF5B24441578000B7707 /* TXLiteAVSDK_Player.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4071CF5924441578000B7707 /* TXLiteAVSDK_Player.framework */; }; 40A1DEC22638412E0011E532 /* NSData+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 47E8CAB6260B5C05001CF672 /* NSData+Common.m */; }; 40A1DED8263841360011E532 /* NSDictionary+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 47E8CAC5260B5C05001CF672 /* NSDictionary+Common.m */; }; 40A1DEF52638413F0011E532 /* NSObject+CommonBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 47E8CAB3260B5C05001CF672 /* NSObject+CommonBlock.m */; }; @@ -176,7 +175,6 @@ 402A010724506F9C0037A219 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = App/Info.plist; sourceTree = ""; }; 4030B1EC245563B200CF5926 /* SuperPlayer.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SuperPlayer.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 40407ACA1F3035CA006C7301 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 4071CF5924441578000B7707 /* TXLiteAVSDK_Player.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = TXLiteAVSDK_Player.framework; sourceTree = ""; }; 4071CF702444477A000B7707 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; }; 40A49D5E24598CD200BFCB18 /* UGCKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = UGCKit.xcodeproj; path = UGCKit/UGCKit.xcodeproj; sourceTree = ""; }; 40A7CFED2461102E00E792A5 /* SuperPlayer.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = SuperPlayer.bundle; path = SuperPlayer/Resource/SuperPlayer.bundle; sourceTree = ""; }; @@ -384,7 +382,6 @@ 400922E21F4FCC6E009B882D /* AVFoundation.framework in Frameworks */, 400922E31F4FCC6E009B882D /* MediaPlayer.framework in Frameworks */, 400922E51F4FCC6E009B882D /* libiconv.tbd in Frameworks */, - 4071CF5B24441578000B7707 /* TXLiteAVSDK_Player.framework in Frameworks */, 400922E61F4FCC6E009B882D /* libz.tbd in Frameworks */, 400922E71F4FCC6E009B882D /* libc++.tbd in Frameworks */, 400922E91F4FCC6E009B882D /* libresolv.tbd in Frameworks */, @@ -510,7 +507,6 @@ 40F852FA1EE8FB3800EE47D7 = { isa = PBXGroup; children = ( - 45736E91243F5B2200F7F601 /* SDK */, 40F853051EE8FB3800EE47D7 /* TXLiteAVDemo */, 40F854FF1EE8FD2F00EE47D7 /* Frameworks */, 40F853041EE8FB3800EE47D7 /* Products */, @@ -622,15 +618,6 @@ name = Frameworks; sourceTree = ""; }; - 45736E91243F5B2200F7F601 /* SDK */ = { - isa = PBXGroup; - children = ( - 4071CF5924441578000B7707 /* TXLiteAVSDK_Player.framework */, - ); - name = SDK; - path = ../SDK; - sourceTree = ""; - }; 45D8448A23B63C77001CD3A9 /* UGCUpload */ = { isa = PBXGroup; children = ( diff --git a/Demo/TXLiteAVDemo.xcodeproj/xcshareddata/xcschemes/TXLiteAVDemo_Player.xcscheme b/Demo/TXLiteAVDemo.xcodeproj/xcshareddata/xcschemes/TXLiteAVDemo_Player.xcscheme index a2c06e99..15660be9 100644 --- a/Demo/TXLiteAVDemo.xcodeproj/xcshareddata/xcschemes/TXLiteAVDemo_Player.xcscheme +++ b/Demo/TXLiteAVDemo.xcodeproj/xcshareddata/xcschemes/TXLiteAVDemo_Player.xcscheme @@ -1,28 +1,10 @@ + version = "1.3"> - - - - - - - - - - ["$(PODS_TARGET_SRCROOT)/#{framework_path}/Headers"] - } end spec.subspec "Professional" do |s| s.source_files = 'SuperPlayer/**/*.{h,m}' s.private_header_files = 'SuperPlayer/Utils/TXBitrateItemHelper.h', 'SuperPlayer/Views/SuperPlayerView+Private.h' # s.resource = 'SuperPlayer/Resource/*' - framework_path="../../../SDK/TXLiteAVSDK_Professional.framework" - s.pod_target_xcconfig={ - 'HEADER_SEARCH_PATHS'=>["$(PODS_TARGET_SRCROOT)/#{framework_path}/Headers"] - } end spec.subspec "Enterprise" do |s| s.source_files = 'SuperPlayer/**/*.{h,m}' s.private_header_files = 'SuperPlayer/Utils/TXBitrateItemHelper.h', 'SuperPlayer/Views/SuperPlayerView+Private.h' # s.resource = 'SuperPlayer/Resource/*' - framework_path="../../../SDK/TXLiteAVSDK_Enterprise.framework" - s.pod_target_xcconfig={ - 'HEADER_SEARCH_PATHS'=>["$(PODS_TARGET_SRCROOT)/#{framework_path}/Headers"] - } end spec.subspec "Smart" do |s| s.source_files = 'SuperPlayer/**/*.{h,m}' s.private_header_files = 'SuperPlayer/Utils/TXBitrateItemHelper.h', 'SuperPlayer/Views/SuperPlayerView+Private.h' # s.resource = 'SuperPlayer/Resource/*' - framework_path="../../../SDK/TXLiteAVSDK_Smart.framework" - s.pod_target_xcconfig={ - 'HEADER_SEARCH_PATHS'=>["$(PODS_TARGET_SRCROOT)/#{framework_path}/Headers"] - } end spec.subspec "UGC" do |s| s.source_files = 'SuperPlayer/**/*.{h,m}' s.private_header_files = 'SuperPlayer/Utils/TXBitrateItemHelper.h', 'SuperPlayer/Views/SuperPlayerView+Private.h' # s.resource = 'SuperPlayer/Resource/*' # framework_path="Frameworks/TXLiteAVSDK_UGC.framework" - framework_path="../../../SDK/TXLiteAVSDK_UGC.framework" - s.pod_target_xcconfig={ - 'HEADER_SEARCH_PATHS'=>["$(PODS_TARGET_SRCROOT)/#{framework_path}/Headers"] - } end # spec.subspec "UGC_PITU" do |s| # s.dependency 'SuperPlayer/Core' diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m index 4615d156..177c0118 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/Skins/SPDefaultControlView.m @@ -289,7 +289,7 @@ - (void)resolutionBtnClick:(UIButton *)sender { self.resolutionView.hidden = NO; [DataReport report:@"change_resolution" param:nil]; - [self cancelFadeOut]; + [self fadeShow]; self.isShowSecondView = YES; } diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.h b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.h index 25f74c73..994e7cf8 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.h +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.h @@ -11,6 +11,36 @@ @class TXVipTipView; @class TXVipWatchView; @class TXVipWatchModel; +@class TXLivePlayer; +@class TXVodPlayer; + +@protocol SuperPlayerPlayListener +@optional + +/// 直播事件通知 +/// @param player 直播播放器 +/// @param evtID 参见 TXLiveSDKEventDef.h +/// @param param 参见 TXLiveSDKTypeDef.h +- (void)onLivePlayEvent:(TXLivePlayer *)player event:(int)evtID withParam:(NSDictionary *)param; + +/// 直播网络状态通知 +/// @param player 直播播放器 +/// @param param 参见 TXLiveSDKTypeDef.h +- (void)onLiveNetStatus:(TXLivePlayer *)player withParam:(NSDictionary *)param; + +/// 点播事件通知 +/// @param player 点播播放器 +/// @param evtID 参见TXLiveSDKTypeDef.h +/// @param param 参见TXLiveSDKTypeDef.h +- (void)onVodPlayEvent:(TXVodPlayer *)player event:(int)evtID withParam:(NSDictionary *)param; + +/// 点播网络状态通知 +/// @param player 点播播放器 +/// @param param 参见TXLiveSDKTypeDef.h +- (void)onVodNetStatus:(TXVodPlayer *)player withParam:(NSDictionary *)param; + +@end + @protocol SuperPlayerDelegate @optional /// 返回事件 @@ -34,6 +64,7 @@ typedef NS_ENUM(NSInteger, SuperPlayerState) { StatePlaying, // 播放中 StateStopped, // 停止播放 StatePause, // 暂停播放 + StateFirstFrame, // 第一帧画面 }; /// 播放器布局样式 @@ -47,6 +78,8 @@ typedef NS_ENUM(NSInteger, SuperPlayerLayoutStyle) { /** 设置代理 */ @property(nonatomic, weak) id delegate; +@property(nonatomic, weak) id playListener; + @property(nonatomic, assign) SuperPlayerLayoutStyle layoutStyle; /// 设置播放器的父view。播放过程中调用可实现播放窗口转移 diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m index 4dff5904..4c3ddbf2 100644 --- a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer/SuperPlayerView.m @@ -339,6 +339,7 @@ - (void)resume { } else { if (self.state == StatePause) { [self.vodPlayer resume]; + self.state = StatePlaying; if (self.delegate && [self.delegate respondsToSelector:@selector(superPlayerDidStart:)]) { [self.delegate superPlayerDidStart:self]; } @@ -586,7 +587,7 @@ - (void)configTXPlayer { - (void)setVodPlayConfig { TXVodPlayConfig *config = [[TXVodPlayConfig alloc] init]; - config.smoothSwitchBitrate = YES; + config.smoothSwitchBitrate = NO; if (self.playerConfig.maxCacheItem) { // https://github.com/tencentyun/SuperPlayer_iOS/issues/64 config.cacheFolderPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/TXCache"]; @@ -1143,6 +1144,11 @@ - (void)appDidEnterPlayground:(NSNotification *)notify { if (!self.isPauseByUser && (self.state != StateStopped && self.state != StateFailed)) { self.state = StatePlaying; [_vodPlayer resume]; + CGFloat value = _vodPlayer.currentPlaybackTime / _vodPlayer.duration; + CGFloat playable = _vodPlayer.playableDuration / _vodPlayer.duration; + self.controlView.isDragging = NO; + [self.controlView setProgressTime:self.playCurrentTime totalTime:_vodPlayer.duration progressValue:value playableValue:playable]; + [self fastViewUnavaliable]; } } @@ -1484,6 +1490,9 @@ - (void)setState:(SuperPlayerState)state { [[NSNotificationCenter defaultCenter] removeObserver:self name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; + + } else if (state == StateFirstFrame) { + _state = StatePlaying; if (self.coverImageView.alpha == 1) { [UIView animateWithDuration:0.2 animations:^{ @@ -1871,6 +1880,10 @@ - (void)_removeOldPlayer { } - (void)onPlayEvent:(TXVodPlayer *)player event:(int)EvtID withParam:(NSDictionary *)param { + if ((int)player.duration == 102) { + NSLog(@"simonplu---onPlayEvent:%d:%@:%f:%d",EvtID,player,player.duration,player.isPlaying); + } + dispatch_async(dispatch_get_main_queue(), ^{ if (EvtID != PLAY_EVT_PLAY_PROGRESS) { NSString *desc = [param description]; @@ -1878,23 +1891,27 @@ - (void)onPlayEvent:(TXVodPlayer *)player event:(int)EvtID withParam:(NSDictiona } float duration = self->_playerModel.duration > 0 ? self->_playerModel.duration : player.duration; + + if (EvtID == PLAY_EVT_RCV_FIRST_I_FRAME) { + self.state = StateFirstFrame; + } - if (EvtID == PLAY_EVT_PLAY_BEGIN || EvtID == PLAY_EVT_RCV_FIRST_I_FRAME) { + if (EvtID == EVT_VIDEO_PLAY_BEGIN) { [self setNeedsLayout]; [self layoutIfNeeded]; self.isLoaded = YES; [self _removeOldPlayer]; [self.vodPlayer setupVideoWidget:self insertIndex:0]; [self layoutSubviews]; // 防止横屏状态下添加view显示不全 - self.state = StatePlaying; [self updateBitrates:player.supportedBitrates]; for (SPVideoFrameDescription *p in self.keyFrameDescList) { if (player.duration > 0) p.where = p.time / duration; } self.controlView.pointArray = self.keyFrameDescList; - + self.state = StatePlaying; [self.controlView setPlayState:YES]; + self.centerPlayBtn.hidden = YES; self.controlView.hidden = SuperPlayerWindowShared.isShowing ? YES : NO; // 不使用vodPlayer.autoPlay的原因是暂停的时候会黑屏,影响体验 @@ -1912,11 +1929,10 @@ - (void)onPlayEvent:(TXVodPlayer *)player event:(int)EvtID withParam:(NSDictiona CGFloat totalTime = duration; CGFloat value = player.currentPlaybackTime / duration; CGFloat playable = player.playableDuration / duration; - - [self.vipWatchView setCurrentTime:self.playCurrentTime]; if (self.state == StatePlaying) { [self.controlView setProgressTime:self.playCurrentTime totalTime:totalTime progressValue:value playableValue:playable]; + [self.vipWatchView setCurrentTime:self.playCurrentTime]; } } else if (EvtID == PLAY_EVT_PLAY_END) { @@ -1935,6 +1951,26 @@ - (void)onPlayEvent:(TXVodPlayer *)player event:(int)EvtID withParam:(NSDictiona self.videoRatio = (GLfloat)player.width / player.height; } } + + [self onVodPlayEvent:player event:EvtID withParam:param]; + }); +} + +- (void)onVodPlayEvent:(TXVodPlayer *)player event:(int)evtID withParam:(NSDictionary *)param +{ + if ([self.playListener respondsToSelector:@selector(onVodPlayEvent:event:withParam:)]) { + [self.playListener onVodPlayEvent:player event:evtID withParam:param]; + } +} + +-(void) onNetStatus:(TXVodPlayer *)player withParam:(NSDictionary*)param +{ + NSDictionary *dict = param; + + dispatch_async(dispatch_get_main_queue(), ^{ + if ([self.playListener respondsToSelector:@selector(onVodNetStatus:withParam:)]) { + [self.playListener onVodNetStatus:player withParam:dict]; + } }); } @@ -2039,6 +2075,21 @@ - (void)onPlayEvent:(int)EvtID withParam:(NSDictionary *)param { [self.controlView setProgressTime:self.maxLiveProgressTime totalTime:-1 progressValue:1 playableValue:0]; } } + + if ([self.playListener respondsToSelector:@selector(onLivePlayEvent:event:withParam:)]) { + [self.playListener onLivePlayEvent:self.livePlayer event:EvtID withParam:dict]; + } + }); +} + +- (void)onNetStatus:(NSDictionary *)param +{ + NSDictionary *dict = param; + + dispatch_async(dispatch_get_main_queue(), ^{ + if ([self.playListener respondsToSelector:@selector(onLiveNetStatus:withParam:)]) { + [self.playListener onLiveNetStatus:self.livePlayer withParam:dict]; + } }); } diff --git a/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer_Flutter.podspec b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer_Flutter.podspec new file mode 100644 index 00000000..6f9c71fb --- /dev/null +++ b/Demo/TXLiteAVDemo/SuperPlayerKit/SuperPlayer_Flutter.podspec @@ -0,0 +1,55 @@ +Pod::Spec.new do |spec| + spec.name = 'SuperPlayer' + spec.version = '3.1.1' + spec.license = { :type => 'MIT' } + spec.homepage = 'https://cloud.tencent.com/product/player' + spec.authors = { 'annidyfeng' => 'annidyfeng@tencent.com' } + spec.summary = '超级播放器' + spec.source = { :git => 'https://github.com/tencentyun/SuperPlayer_iOS.git', :tag => 'v3.1.1' } + + spec.ios.deployment_target = '8.0' + spec.requires_arc = true + + spec.dependency 'AFNetworking' + spec.dependency 'SDWebImage' + spec.dependency 'Masonry' + #spec.dependency 'MMLayout' + + spec.static_framework = true + spec.default_subspec = 'Player' + + spec.ios.framework = ['SystemConfiguration','CoreTelephony', 'VideoToolbox', 'CoreGraphics', 'AVFoundation', 'Accelerate'] + spec.ios.library = 'z', 'resolv', 'iconv', 'stdc++', 'c++', 'sqlite3' + + # spec.subspec "Core" do |s| + # s.source_files = 'SuperPlayer/**/*.{h,m}' + # s.resource = 'SuperPlayer/Resource/*' + # end +# spec.resource = 'SuperPlayer/Resource/*' + + spec.subspec "Player" do |s| + s.source_files = 'SuperPlayer/**/*.{h,m}' + s.private_header_files = 'SuperPlayer/Utils/TXBitrateItemHelper.h', 'SuperPlayer/Views/SuperPlayerView+Private.h' + s.resource = 'SuperPlayer/Resource/*' +#如果要使用cocopods管理的TXLiteAVSDK_Player,就不注释这一行 + s.dependency 'TXLiteAVSDK_Player' + end + spec.subspec "Professional" do |s| + s.source_files = 'SuperPlayer/**/*.{h,m}' + s.private_header_files = 'SuperPlayer/Utils/TXBitrateItemHelper.h', 'SuperPlayer/Views/SuperPlayerView+Private.h' + s.resource = 'SuperPlayer/Resource/*' + s.dependency 'TXLiteAVSDK_Professional' + end + + spec.frameworks = ["SystemConfiguration", "CoreTelephony", "VideoToolbox", "CoreGraphics", "AVFoundation", "Accelerate"] + spec.libraries = [ + "z", + "resolv", + "iconv", + "stdc++", + "c++", + "sqlite3" + ] +end + +# pod trunk push SuperPlayer.podspec --verbose --use-libraries --allow-warnings diff --git a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/Tools/TXVideoPlayer/TXVideoPlayer.m b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/Tools/TXVideoPlayer/TXVideoPlayer.m index d0039284..5968ede4 100644 --- a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/Tools/TXVideoPlayer/TXVideoPlayer.m +++ b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/Tools/TXVideoPlayer/TXVideoPlayer.m @@ -158,7 +158,8 @@ - (TXVodPlayer *)player { _player.enableHWAcceleration = YES; _player.vodDelegate = self; TXVodPlayConfig *config = [TXVodPlayConfig new]; - config.maxBufferSize = 1; + config.maxBufferSize = 3; + config.maxBufferSize = 8; config.smoothSwitchBitrate = NO; _player.config = config; [_player setRenderMode:RENDER_MODE_FILL_SCREEN]; diff --git a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/SuperShortVideoView.m b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/SuperShortVideoView.m index 38513689..1508b584 100644 --- a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/SuperShortVideoView.m +++ b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/SuperShortVideoView.m @@ -61,8 +61,6 @@ @interface SuperShortVideoView() 0) { - [self.currentPlayer playVideoWithView:cell.baseView.coverImgView url:url]; + [self.currentPlayer playVideoWithView:cell.baseView.videoFatherView url:url]; } } @@ -344,10 +342,6 @@ - (void)player:(TXVideoPlayer *)player statusChanged:(TXVideoPlayerStatus)status switch (status) { case TXVideoPlayerStatusUnload: break; - case TXVideoPlayerStatusPrepared: { - [self.currentPlayingCell startLoading]; - } - break; case TXVideoPlayerStatusLoading: [self.currentPlayingCell hidePlayBtn]; break; @@ -614,25 +608,10 @@ - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)ce self.willPlayIndexPath = indexPath; } -- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { - self.isDragging = YES; -} - - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - if (self.isDragging) { - return; - } - CGFloat oldContentOffsetY = self.lastContentOffsetY; self.lastContentOffsetY = scrollView.contentOffset.y; - - NSTimeInterval now = [[NSDate date] timeIntervalSince1970]; - if (now - self.lastCheckPlayTimeInAdvance < 0.05) { - return; - } - self.lastCheckPlayTimeInAdvance = now; - - if (self.lastContentOffsetY > oldContentOffsetY) { + if ((self.lastContentOffsetY > oldContentOffsetY) && self.lastContentOffsetY >= self.willPlayIndexPath.row * SCREEN_HEIGHT) { // scroll up if (self.currentPlayIndex < self.willPlayIndexPath.row) { NSIndexPath *currentIndexPath = [self.tableView currentIndexPathForFullScreenCell]; @@ -642,7 +621,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { } } } - } else { + } else if ((self.lastContentOffsetY < oldContentOffsetY) && self.lastContentOffsetY <= self.willPlayIndexPath.row * SCREEN_HEIGHT) { // scroll down if (self.currentPlayIndex > self.willPlayIndexPath.row) { NSIndexPath *currentIndexPath = [self.tableView currentIndexPathForFullScreenCell]; @@ -661,7 +640,6 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { - self.isDragging = NO; if (!decelerate) { //滑动播放 [self handleScrollPlaying:scrollView]; diff --git a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.h b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.h index 457a974f..45251675 100644 --- a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.h +++ b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.h @@ -47,6 +47,9 @@ NS_ASSUME_NONNULL_BEGIN // 视频播放时长和总时长控件 @property (nonatomic, strong) TXTimeView *timeView; +// 视频播放view +@property (nonatomic, strong) UIView *videoFatherView; + /** * 设置slider的进度条 * @param progress 进度条大小 diff --git a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.m b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.m index 24d717f4..a2cb94b3 100644 --- a/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.m +++ b/Demo/TXLiteAVDemo/UGCShortVideoPlayDemo/View/TXBaseView/TXVideoBaseView.m @@ -26,6 +26,7 @@ - (instancetype)init { if (self = [super init]) { [self addSubview:self.coverImgView]; + [self addSubview:self.videoFatherView]; [self addSubview:self.playBtn]; [self addSubview:self.sliderView]; [self addSubview:self.timeView]; @@ -34,6 +35,10 @@ - (instancetype)init { make.edges.equalTo(self); }]; + [self.videoFatherView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self); + }]; + [self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self); make.width.mas_equalTo(80); @@ -69,7 +74,7 @@ - (void)setModel:(TXVideoModel *)model { // }else { // self.coverImgView.contentMode = UIViewContentModeScaleAspectFill; // } - + [self hidePlayBtn]; self.coverImgView.contentMode = UIViewContentModeScaleAspectFit; if (model.coverUrl) { @@ -117,8 +122,7 @@ - (NSString *)detailCurrentTime:(int)currentTime totalTime:(int)totalTime { #pragma mark - Action - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - NSTimeInterval delayTime = 0.3f; - [self performSelector:@selector(controlViewDidClick) withObject:nil afterDelay:delayTime]; + [self controlViewDidClick]; } - (void)controlViewDidClick { @@ -195,4 +199,12 @@ - (TXTimeView *)timeView { return _timeView; } +- (UIView *)videoFatherView { + if (!_videoFatherView) { + _videoFatherView = [[UIView alloc] init]; + _videoFatherView.backgroundColor = [UIColor clearColor]; + } + return _videoFatherView; +} + @end diff --git a/README.md b/README.md index db94d11b..bed41375 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ 本目录包含 iOS 版 播放器(Player) SDK 的Demo 源代码,主要演示接口如何调用以及最基本的功能。 ``` -├─ SDK -| ├─ TXLiteAVSDK_Player.framework // 播放器的framework静态库 ├─ Demo // 超级播放器Demo └── TXLiteAVDemo ├── App // 程序入口界面 diff --git a/SDK/README.md b/SDK/README.md deleted file mode 100644 index 6f9501cd..00000000 --- a/SDK/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Player SDK (iOS) - -## 下载地址 - - -[下载 iOS Player SDK](https://liteav.sdk.qcloud.com/download/latest/TXLiteAVSDK_Player_iOS_latest.zip) - -> Demo 编译时会自动下载SDK到此目录。