I want to run youtube embedded video from a timestamp. I know how to do this in browsers, but it does not work on iPhone. Here is a detailed MATT CUTTS tutorial.
Play embedded video with a specific timestamp
In the link above, you can see if we added # t = 31m08s or / start = 200 to the url, but when I use the same url inside the UiWebView, the youtube player by default starts the video from the first frame. Maybe someone has an idea or it was implemented. I am using a UIWebView with a built-in tag to play videos on YouTube. I am using the inline tag below inside a UIWebView.
<embed id="yt" src="http://www.youtube.com/watch?v=dsFQ9kM1qDs" type="application/x-shockwave-flash" width= "500" height="400"></embed>
Below is the code I use to play this video in UIWebView
- (IBAction) playYoutube {
[self embedYouTube:@"http://www.youtube.com/watch?v=dsFQ9kM1qDs#t=2m08s"];
}
- (void)embedYouTube:(NSString*)url
{
[webView setFrame:CGRectMake(0, 0, 480, 320)];
NSString* embedHTML = @"\
<html><head>"
"<style type=\"text/css\">"
"body {"
"background-color: transparent;"
"color: white;"
"} </style>"
"</head><body style=\"margin:0\">"
" <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" "
"width=\"%0.0f\" height=\"%0.0f\"></embed>"
" </body></html>";
NSString* html = [NSString stringWithFormat:embedHTML, url, webView.frame.size.width, webView.frame.size.height];
[webView loadHTMLString:html baseURL:nil];
}