2011-06-20 286 views
0

我编写的代码如下,在youtube嵌入式播放器中播放视频。 它打开播放器窗口并显示视频,但不播放。在iphone中播放视频播放器中的视频播放器

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]; 
    } 

你能告诉我,代码中有什么问题。

谢谢。

回答

1

iOS不支持Flash,你应该使用HTML 5的新标签video包裹的视频网址是这样的:

<video src="point/to/mov"></video>

+0

那不是真实的,你仍然可以在播放嵌入的内容从YouTube youtube播放器。尽管如此,iOs不支持Flash。 –

+0

anyways..it不玩在模拟器和设备也 –

+0

请确保您的视频网址可以在iOS上播放,说,mov或mp4格式,而不是flv。 – cxa