如何嵌入包含受版权保护内容的Youtube视频.
例如,当您尝试在UIWebView中播放此视频(http://www.youtube.com/embed/ADBKdSCbmiM)时,它说
This Video Contains content from Vevo. It is restricted from playback on certain sites
我如何才能将这样的视频用于嵌入式播放器或使用MPMoviePlayer等制作的自定义播放器.我知道这是可能的,因为下面的应用程序这样做. (http://itunes.apple.com/us/app/audioviz-view-your-songs-on/id547001249?mt=8)
编辑
很少有视频在浏览器中播放,但在iOS模拟器中显示
This video contains content from SME . It is restricted from playback on certain site
感谢您的帮助!
解决方法
要使用uiwebview播放youtube视频:
>首先检查浏览器中是否播放了您的YouTube网址.如果视频无法在浏览器中播放,则它也不会在设备中播放
>您只需检查设备;视频无法在模拟器中播放
- (void) displayGoogleVideo { CGRect rect = [[UIScreen mainScreen] bounds]; CGSize screenSize = rect.size; UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,screenSize.width,screenSize.height)]; webView.autoresizesSubviews = YES; webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth); NSString *videoUrl = @"http://www.youtube.com/v/oHg5SJYRHA0"; // valid youtube url NSString *htmlString = [NSString stringWithFormat:@"<html><head><Meta name = \"viewport\" content = \"initial-scale = 1.0,user-scalable = no,width = 212\"/></head><body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"320\" height=\"480\"><param name=\"movie\" value=\"%@\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"%@\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"320\" height=\"480\"></embed></object></div></body></html>",videoUrl,videoUrl] ; [webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.youtube.com"]]; [window addSubview:webView]; [webView release]; }