嵌入Youtube视频: - 包含来自*的内容,限制在特定网站上播放

Shr*_*794 8 embed youtube cocoa-touch ipad ios

如何嵌入包含受版权保护内容的Youtube视频.

例如,当您尝试播放此视频(http://www.youtube.com/embed/ADBKdSCbmiM的)UIWebView,它说

 This Video Contains content from Vevo. It is restricted from playback on certain sites
Run Code Online (Sandbox Code Playgroud)

我将如何将这样的视频用于嵌入式播放器或我将使用的自定义播放器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
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助!

atu*_*tri 8

您可以player vars在初始化youtube sdk时使用:

NSDictionary *playerVars = @{
                             @"origin" : @"http://www.youtube.com",
                             };
[self.playerView loadWithVideoId:@"KOvoD1upTxM" playerVars:playerVars];
Run Code Online (Sandbox Code Playgroud)

请享用!


iCr*_*Dev 3

要播放 YouTube 视频,请使用uiwebview

  1. 首先检查您的 YouTube URL 是否在浏览器中播放。如果视频无法在浏览器中播放,它也不会在设备中播放

  2. 您只需签入设备即可;视频无法在模拟器中播放

    - (void) displayGoogleVideo
    
        {
    
        CGRect rect = [[UIScreen mainScreen] bounds];
    
        CGSize screenSize = rect.size;
    
        UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,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]; 
    
    }
    
    Run Code Online (Sandbox Code Playgroud)