I am loading an i frame url in webview but when i click on play button it is loading to full screen but i need to stop that
Here i need to load the url with in the webview frame only it should not go to full screen mode
I have tried the following code but still i am getting the full screen mode.
` override func viewDidLoad() {
super.viewDidLoad()
// Set up the WKWebViewConfiguration
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
if #available(iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = []
} else {
configuration.requiresUserActionForMediaPlayback = false
}
webView = WKWebView(frame: CGRect(x: 20, y: 50, width: 300, height: 250))
webView.navigationDelegate = self
self.view.addSubview(webView)
// Load the iframe
loadIframe()
}
func loadIframe() {
let iframeURL = "https://instaview.instavc.com/player/embed_player.php?vid=1040&width=300&height=250&autoplay=no"
let htmlString = """
<!DOCTYPE html>
<html>
<head>
<style>
body, html {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
}
iframe {
border: none;
width: 100%;
height: 100%;
}
video::-webkit-media-controls-fullscreen-button {
display: none;
}
</style>
</head>
<body>
<iframe id="videoPlayer" src="(iframeURL)" allow="autoplay"></iframe>
<script>
document.addEventListener('DOMContentLoaded', function() {
var iframe = document.getElementById('videoPlayer');
iframe.addEventListener('webkitfullscreenchange', function() {
if (document.webkitIsFullScreen) {
document.webkitExitFullscreen();
}
}, false);
});
</script>
</body>
</html>
"""
webView.loadHTMLString(htmlString, baseURL: nil)
}
`
The above class is the sample class i have tried to load the url in webview
but i need to prevent the video loading into the full screen
Abdul Mazeed Shaik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.