Я написал следующий код для воспроизведения видео на встроенном плеере YouTube.
Он открывает окно плеера и показывает видео, но не играет.
if(self.isYouTube)
{
NSString *embedHTML;
NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"4.3" options: NSNumericSearch];
if (order == NSOrderedSame || order == NSOrderedDescending) {
embedHTML = @"<html><head><style type=\"text/css\">body {background-color:black; color:black; margin-right:auto; margin-left:auto;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" airplay=\"allow\" type=\"application/x-shockwave-flash\" position=\"fixed\" allowfullscreen=\"true\" autoplay=\"1\" width=\"320.0\" height=\"460.0\"></embed></body></html>";
} else {
embedHTML = @"<html><head><style type=\"text/css\">body {background-color:black; color:black; margin-right:auto; margin-left:auto;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" position=\"fixed\" allowfullscreen=\"true\" autoplay=\"1\" width=\"320.0\" height=\"460.0\"></embed></body></html>";
}
NSString *contentHtml = [NSString stringWithFormat:embedHTML,self.url];
[self.webView setBackgroundColor:[UIColor blackColor]];
[self.webView loadHTMLString:contentHtml baseURL:nil];
}
else
{
NSURL *urlForOpenFile=[NSURL URLWithString:self.url];
NSURLRequest *request=[NSURLRequest requestWithURL:urlForOpenFile];
[self.webView loadRequest:request];
}
Можете ли вы сказать мне, в чем проблема в коде.
Спасибо.