I found a way to play youtube in webview
And this is my sample code :
NSString *youtubeHtmlStr = [NSString stringWithFormat:@"<iframe class=\"youtube-player\" type=\"text/html\" width=\"328\" height=\"270\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\"></iframe>",videoPath];
[webView loadHTMLString:youtubeHtmlStr baseURL:nil];
How to know the movie is playing now ???
When I click play icon , It log a message
setting movie path:
http://o-o.preferred.fareastone-khh1.v3.lscache5.c.youtube.com/ …
But I have no idea who log this message ???
Hope someone know the answer
Many thanks
Webber
What you will have to do with html is to use java-script. Didn’t try it with Youtube personally, but Google documentation might be helpful: http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en//events/io/2011/static/presofiles/youtube_iframe_player_the_future_of_embedding.pdf
In order to handle playback events inside your objective-c code, you could navigate the webpage to the url’s like myplayer://stopped handle it with webview delegate method, of course not allowing it to change the page. that way the url will tell you what happened inside the html.