Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone sdk 3.0 如何在iphone应用程序中播放youtube视频?_Iphone Sdk 3.0_Ios Simulator - Fatal编程技术网

Iphone sdk 3.0 如何在iphone应用程序中播放youtube视频?

Iphone sdk 3.0 如何在iphone应用程序中播放youtube视频?,iphone-sdk-3.0,ios-simulator,Iphone Sdk 3.0,Ios Simulator,我想用url在我的应用程序中播放Youtube视频。我尝试了以下代码,但无效 NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/v/pGqraZN5U0k&amp"]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; if (moviePlayer) {

我想用url在我的应用程序中播放Youtube视频。我尝试了以下代码,但无效

   NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/v/pGqraZN5U0k&amp"];
   MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
   if (moviePlayer)
   {
     [self.moviePlayer play];
   }
请帮帮我


提前感谢。

YouTube视频无法在MPMoviePlayerController中直接播放。您必须启动YouTube应用程序或创建UIWebView来显示视频。见以下问题:

NSString*youTubeVideoHTML=@”\
\
\
";
NSString*html=[NSString stringWithFormat:youtube视频链接,self.webView.frame.size.width,self.webView.frame.size.height];
NSLog(@“html%@”,html);
[self.webView loadHTMLString:html baseURL:nil];
NSString *youTubeVideoHTML = @"<html><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:youTubeVideoHTML, youtube video link, self.webView.frame.size.width, self.webView.frame.size.height];
NSLog(@"html %@",html);
[self.webView loadHTMLString:html baseURL:nil];