1
votes

I have video embedded in my application using this solution (html string in UIWebView): http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application

Unfortunately client requires his own thumbnail. I would like to solve it by creating UIWebView once he taps on this thumbnail and play the video inside automatically.

How can I do it?

2
Ok, I don't like this kind of solution and I honestly want something like iApple posted works but I found this and it works: boydlee.com/ios-iphone-ipad/… What is same as here (finally find it via google): stackoverflow.com/questions/5510429/…Engeor

2 Answers

0
votes

Try this:-

NSString *htmlString = [NSString stringWithFormat:@"<html><head>"
                        "<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 50\"/></head>"
                        "<body style=\"background:#F00;margin-top:0px;margin-left:0px\">"
                        "<div><object width=\"50\" height=\"50\">"
                        "<param name=\"movie\" value=\"%@\"></param>"
                        "<param name=\"wmode\" value=\"transparent\"></param>"
                        "<embed src=\"%@\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"50\" height=\"50\"></embed>"
                        "</object></div></body></html>",[d objectForKey:@"hrefUrl"],[d objectForKey:@"hrefUrl"]];

[videoView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.your-url.com"]];
-2
votes

Following is the html string to play video automatically inside UIWebView...

NSString *embedHTML = [NSString stringWithFormat:@"<html><body><video controls=\"controls\" autoplay=\"autoplay\"><source src=\"%@\" type=\"video/mp4\"/></video></body></html>", url];
[_webView loadHTMLString:embedHTML baseURL:baseURL];

I have tried the following one, it is working fine and also starts to play automatically.

NSString *embedHTML = @"<html><body bgcolor="black"><embed id="yt" src="http://www.youtube.com/watch?v=9vyYHVB-QnY"type="application/x-shockwave-flash" width="320.00" height="370.00"></embed></body></html>";
[_webView loadHTMLString:embedHTML baseURL:baseURL];