| | |
| | | #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; |
| | |
| | | [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 { |
| | |
| | | [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]]; |
| | |
| | | |
| | | - (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]; |
| | |
| | | //设置请求的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; |
| | | // 是否允许手势左滑返回上一级, 类似导航控制的左滑返回 |
| | |
| | | - (PPTVBottomVIpVIew *)viewPPTVVip { |
| | | if (!_viewPPTVVip) { |
| | | _viewPPTVVip = [[PPTVBottomVIpVIew alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH)]; |
| | | // _viewPPTVVip.hidden = YES; |
| | | //_viewPPTVVip.hidden = YES; |
| | | // _viewPPTVVip.delegate = self; |
| | | } |
| | | return _viewPPTVVip; |