Does the Watch on youtube link not work with iOS UIWebView?

I integrated YouTube iTrame to play videos on the UIWebView webpage.

The watch on youtube link does not work:

enter image description here

Code:

<iframe name="player" id="player" src="http://www.youtube.com/embed/{$firstParsedVideo}?HD=1;rel=0;showinfo=0" width="279" height="155"></iframe> 

where $ firstParsedVideo is the identifier of the video.

I did the same in Cocoa Osx WebView and it works great.

thanks

+4
source share
2 answers

The reason it doesn't work is because the base URL of the web view is set to local. Since my webview loads local resources (images), I need to set it to local. But this means that I can’t upload online resources (videos from YouTube). Either one or the other.

0
source

As far as I know, Apple does not allow you to play Youtube videos in WebView in their own application, and they will also reject your application. Because I have this experience before.

Btw I wrote a Youtube video playback method in my application:

 - (void)embedYouTube:(NSString*)videoId frame:(CGRect)frame { NSString* embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"http://www.youtube.com/watch?v=%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSString* html = [NSString stringWithFormat:embedHTML, videoId, frame.size.width, frame.size.height]; [self.webView loadHTMLString:html baseURL:nil]; } 

Hope this helps.

+1
source

Source: https://habr.com/ru/post/1482188/


All Articles