I am getting an issue while playing a youtube
video using webView
. I am giving one html
string as an input in which youtube
video url
is provided. My webView
is loading successfully. Also in delegate of webViewDidFinishLoad
, I can get the proper url using - webView.request.URL.absoluteString
But strange fact is, I cant see any interface except webview
's background color. This is happening on iOS 9.0.2.
On simulator
of iOS 9.0.
its working fine.
Also, on the device with iOS 8.3
it's working fine. Only on the device of iOS 9.0.2
it's not working.
Below is the code I wrote so far -
NSString *strLink = [NSString stringWithFormat:@"https://www.youtube.com/embed/%@/clean",strVidID];
youTubeVideoHTML = [NSString stringWithFormat:@"\
<html>\
<head>\
<style type=\"text/css\">\
iframe {position:absolute; margin-top:-0px;}\
body {background-color:#000; margin:0;}\
</style>\
</head>\
<body>\
<iframe width=\"100%%\" height=\"100%%\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>\
</body>\
</html>", strLink];
[self.webVwVideoPlayer loadHTMLString:youTubeVideoHTML baseURL:baseURL];
where, self.webVwVideoPlayer
is outlet to UIWebView
.
Also, as per new app transport security, I have modified my plist
file as -
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>youtube.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
Please let me know if anyone know about this.