Skip to content

Commit

Permalink
兼容ZFPlayer最新版本
Browse files Browse the repository at this point in the history
  • Loading branch information
pcjbird committed Jun 20, 2018
1 parent e753e4f commit 8889641
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ target 'QuickWebKit' do
# Pods for QuickWebJSBridgeImagePlayProxy
pod 'IDMPhotoBrowser'
# Pods for QuickWebJSBridgeVideoPlayProxy
pod 'ZFPlayer'
pod 'ZFPlayer/AVPlayer'
pod 'ZFPlayer/ControlView'
# Pods for QuickWebLNRefreshPlugin
pod 'LNRefresh'
# Pods for QuickWebMJRefreshPlugin
Expand Down
5 changes: 3 additions & 2 deletions QuickWebKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QuickWebKit"
s.version = "1.2.8"
s.version = "1.2.9"
s.summary = "A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。"
s.description = <<-DESC
A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。如果您仅想使用其中部分(而非全部插件),您可以根据需要仅安装您需要的功能与插件, 该项目支持 Cocoapods 的 subspec。
Expand Down Expand Up @@ -140,7 +140,8 @@ Pod::Spec.new do |s|
sss.source_files = 'QuickWebKit/QuickWebPlugins/QuickWebJSBridgePlugin/Proxies/ExtProxies/QuickWebJSBridgeVideoPlayProxy.{h,m}'
sss.public_header_files = 'QuickWebKit/QuickWebPlugins/QuickWebJSBridgePlugin/Proxies/ExtProxies/QuickWebJSBridgeVideoPlayProxy.{h}'
sss.dependency 'QuickWebKit/QuickWebViewController'
sss.dependency 'ZFPlayer'
sss.dependency 'ZFPlayer/AVPlayer'
sss.dependency 'ZFPlayer/ControlView'
end

ss.subspec 'QuickWebJSBridgePushMessageProxy' do |sss|
Expand Down
3 changes: 3 additions & 0 deletions QuickWebKit/QuickWebKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// 框架名称:QuickWebKit
// 框架功能:A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
// 修改记录:
// pcjbird 2018-06-20 Version:1.2.9 Build:201806200001
// 1.兼容ZFPlayer最新版本。
//
// pcjbird 2018-04-10 Version:1.2.8 Build:201804100001
// 1.插件新增didCreateJavaScriptContext回调代理。
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
#import "NSString+QuickWeb.h"
#import "UIView+QuickWeb.h"
#import <ZFPlayer/ZFPlayer.h>
#import <ZFPlayer/ZFAVPlayerManager.h>
#import <ZFPlayer/ZFPlayerControlView.h>

@interface QuickWebJSBridgeVideoPlayProxy()<ZFPlayerDelegate>
@interface QuickWebJSBridgeVideoPlayProxy()
{
NSString * _name;
}

@property(nonatomic, weak) id<QuickWebJSInvokeResultHandlerProtocol, SmartJSBridgeProtocol> resultHandler;
@property (weak, nonatomic) ZFPlayerView *videoPlayer;
@property (nonatomic, weak) ZFPlayerController *player;
@property (nonatomic, weak) ZFPlayerControlView *controlView;
@end

@implementation QuickWebJSBridgeVideoPlayProxy
Expand Down Expand Up @@ -111,38 +114,28 @@ -(void) playVideoWithUrl:(NSString*)videoUrl webViewSecretId:(NSString *)secretI
BOOL bAlert = [self whetherRemindUseDataToPlayVideoUnderCelluarNetworks];
void(^playBlock)(void) = ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 0.1f),dispatch_get_main_queue(), ^{
if(![weakSelf.videoPlayer isKindOfClass:[ZFPlayerView class]])
if(![weakSelf.player isKindOfClass:[ZFPlayerController class]])
{
ZFPlayerView *player = [[ZFPlayerView alloc] init];
UIView *playerParentView = [[UIApplication sharedApplication] keyWindow].rootViewController.view;
if([self.resultHandler conformsToProtocol:@protocol(SmartJSBridgeProtocol)])

if([weakSelf.resultHandler conformsToProtocol:@protocol(SmartJSBridgeProtocol)])
{
UIView * webView = [weakSelf.resultHandler getSmartJSWebViewBySecretId:secretId];
if([webView isKindOfClass:[UIView class]])
{
playerParentView = webView;
}
}
[playerParentView addSubview:player];
[playerParentView bringSubviewToFront:player];
CGRect frame = [UIScreen mainScreen].bounds;
[player mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(playerParentView).offset(frame.origin.y);
make.left.equalTo(playerParentView).offset(frame.origin.x);
make.width.equalTo(@(frame.size.width));
make.height.equalTo(@(frame.size.height));
}];
ZFPlayerControlView *controlView = [[ZFPlayerControlView alloc] init];
// model
ZFPlayerModel *playerModel = [[ZFPlayerModel alloc]init];
playerModel.fatherView = playerParentView;
playerModel.videoURL = [NSURL URLWithString:videoUrl];
playerModel.title = @"";
[player playerControlView:controlView playerModel:playerModel];
player.delegate = self;
player.playerLayerGravity = ZFPlayerLayerGravityResizeAspect;
[player autoPlayTheVideo];
weakSelf.videoPlayer = player;
ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
weakSelf.player = [ZFPlayerController playerWithPlayerManager:playerManager containerView:playerParentView];
ZFPlayerControlView* controlView = [ZFPlayerControlView new];
weakSelf.player.controlView = controlView;
weakSelf.controlView = controlView;
[playerParentView bringSubviewToFront:weakSelf.player.currentPlayerManager.view];
weakSelf.player.assetURL = [NSURL URLWithString:videoUrl];
[weakSelf.player enterLandscapeFullScreen:UIInterfaceOrientationLandscapeRight animated:NO];
[weakSelf.controlView.landScapeControlView.backBtn addTarget:weakSelf action:@selector(stop:) forControlEvents:UIControlEventTouchUpInside];

}
else
{
Expand All @@ -155,20 +148,11 @@ -(void) playVideoWithUrl:(NSString*)videoUrl webViewSecretId:(NSString *)secretI
playerParentView = webView;
}
}
[playerParentView addSubview:weakSelf.videoPlayer];
[playerParentView bringSubviewToFront:weakSelf.videoPlayer];
CGRect frame = [UIScreen mainScreen].bounds;
[weakSelf.videoPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(playerParentView).offset(frame.origin.y);
make.left.equalTo(playerParentView).offset(frame.origin.x);
make.width.equalTo(@(frame.size.width));
make.height.equalTo(@(frame.size.height));
}];
ZFPlayerModel *playerModel = [[ZFPlayerModel alloc]init];
playerModel.fatherView = playerParentView;
playerModel.videoURL = [NSURL URLWithString:videoUrl];
playerModel.title = @"";
[weakSelf.videoPlayer resetToPlayNewVideo:playerModel];
[playerParentView addSubview:weakSelf.player.currentPlayerManager.view];
[playerParentView bringSubviewToFront:weakSelf.player.currentPlayerManager.view];
weakSelf.player.assetURL = [NSURL URLWithString:videoUrl];
[weakSelf.player enterLandscapeFullScreen:UIInterfaceOrientationLandscapeRight animated:NO];
[weakSelf.controlView.landScapeControlView.backBtn addTarget:weakSelf action:@selector(stop:) forControlEvents:UIControlEventTouchUpInside];
}

});
Expand Down Expand Up @@ -196,7 +180,7 @@ -(void) playVideoWithUrl:(NSString*)videoUrl webViewSecretId:(NSString *)secretI
alertBlock(nil, NSLocalizedStringFromTableInBundle(@"Network Not Available", @"Localizable", QUICKWEB_BUNDLE, nil));
return;
}
if(bAlert && [self isUnderCelluarNetworks] && !(weakSelf.videoPlayer && weakSelf.videoPlayer.state == ZFPlayerStatePlaying))
if(bAlert && [self isUnderCelluarNetworks] && !(weakSelf.player && weakSelf.player.currentPlayerManager.isPlaying))
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:NSLocalizedStringFromTableInBundle(@"CellularNetworksVideoPlayTip", @"Localizable", QUICKWEB_BUNDLE, nil) preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedStringFromTableInBundle(@"Cancel", @"Localizable", QUICKWEB_BUNDLE, nil) style:UIAlertActionStyleCancel handler:nil];
Expand Down Expand Up @@ -226,6 +210,14 @@ -(void) playVideoWithUrl:(NSString*)videoUrl webViewSecretId:(NSString *)secretI
}
}

-(void)stop:(id)sender
{
if(self.player)
{
[self.player stop];
}
}

-(BOOL) whetherRemindUseDataToPlayVideoUnderCelluarNetworks
{
return YES;
Expand Down
2 changes: 1 addition & 1 deletion QuickWebKit/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.8</string>
<string>1.2.9</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ pod 'QuickWebKit'

## 版本 / Releases

#### 2018-06-20 V1.2.9
![](https://avatars3.githubusercontent.com/u/6175452?s=16) **pcjbird** released build201806200001
> 1.兼容ZFPlayer最新版本。
#### 2018-04-10 V1.2.8
![](https://avatars3.githubusercontent.com/u/6175452?s=16) **pcjbird** released build201804100001
> 1.插件新增didCreateJavaScriptContext回调代理。
Expand Down

0 comments on commit 8889641

Please sign in to comment.