al
liurenjie
2021-07-03 1b73d5d0b495f2d643c2523e1b8399f925b4f702
BuWanVideo2.0/PPTVController.m
@@ -11,11 +11,13 @@
#import "PPTVPppView.h"
#import "PPTVBottomVIpVIew.h"
#import <WebKit/WebKit.h>
#import "dsbridge.h"
#import "JSAPI.h"
@interface PPTVController () <WKNavigationDelegate, WKUIDelegate, WKScriptMessageHandler, PPTVDelegate>
@interface PPTVController () <WKNavigationDelegate, WKUIDelegate, PPTVDelegate>
@property (nonatomic, nullable, strong) WKWebView *webView;
@property (nonatomic, nullable, strong) DWKWebView *webView;
@property (nonatomic, nullable, strong) PPTVNavView *viewPPTVNav;
@property (nonatomic, nullable, strong) PPTVPppView *viewPPTVPop;
@property (nonatomic, nullable, strong) PPTVBottomVIpVIew *viewPPTVVip;
@@ -42,13 +44,13 @@
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    [self.webView.configuration.userContentController addScriptMessageHandler:self name:@"tryPlayFinish"];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"tryPlayFinish"];
}
- (void)loadViewConfig {
@@ -59,7 +61,11 @@
    [self.view addSubview:self.viewPPTVPop];
    [self.view addSubview:self.viewPPTVVip];
    
    self.jsAPI = [[JSAPI alloc] init];
    [self.webView addJavascriptObject:[[JSAPI alloc] init] namespace:@"yestv"];
    [self.webView setDebugMode:true];
    [self.webView customJavascriptDialogLabelTitles:@{@"alertTitle":@"Notification",@"alertBtn":@"OK"}];
    //192.168.3.135
    
    NSString *url = self.parms[@"playUrl"];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
@@ -178,9 +184,14 @@
- (void)afterDelay {
    [self.webView evaluateJavaScript:@"javascript:adPlayFinish()" completionHandler:^(id _Nullable object, NSError * _Nullable error) {}];
    NSString *str = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"js"ofType:@"txt"]   encoding:NSUTF8StringEncoding error:nil];
    [self.webView evaluateJavaScript:str completionHandler:^(id _Nullable object, NSError * _Nullable error) {
        NSLog(@"");
    }];
}
- (WKWebView *)webView {
- (DWKWebView *)webView {
    if (!_webView) {
        // 0.网页配置对象
        WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
@@ -218,7 +229,10 @@
        //设置请求的User-Agent信息中应用程序名称 iOS9后可用
        config.applicationNameForUserAgent = @"ChinaDailyForiPad";
        
        _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.viewPPTVNav.frame), KScreenW, KScreenH - CGRectGetHeight(self.viewPPTVNav.frame)) configuration:config];
        config.suppressesIncrementalRendering = YES;
        _webView = [[DWKWebView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.viewPPTVNav.frame), KScreenW, KScreenH - CGRectGetHeight(self.viewPPTVNav.frame)) configuration:config];
        _webView.UIDelegate = self;
        _webView.navigationDelegate = self;
        // 是否允许手势左滑返回上一级, 类似导航控制的左滑返回
@@ -249,7 +263,7 @@
- (PPTVBottomVIpVIew *)viewPPTVVip {
    if (!_viewPPTVVip) {
        _viewPPTVVip = [[PPTVBottomVIpVIew alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH)];
       // _viewPPTVVip.hidden = YES;
       //_viewPPTVVip.hidden = YES;
       // _viewPPTVVip.delegate = self;
    }
    return _viewPPTVVip;