允许网页自动播放
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.allowsInlineMediaPlayback = YES;
config.mediaPlaybackRequiresUserAction = false;
displayWebView=[[WKWebView alloc] initWithFrame:rect configuration:config];
displayWebView.UIDelegate=self;
displayWebView.navigationDelegate=self;
网页关闭时停止播放
-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
//如果重新返回到这个界面,回空白
//[webViewer loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
//这个会刷新
//[self.webView reload];
//协定方法结束
[self.bridge callHandler:@"WEBCloseAllMedia" data:nil responseCallback:^(id responseData) {
NSLog(@"结束音频:%@",responseData);
}];
}
最好与后台协定一个方法
网友评论