Shredder2794 Shredder2794 - 10 months ago 185
iOS Question

Embed Youtube videos :- with contains content from * , it is restricted from playback on certain site

How to embed a Youtube video that has copyrighted content in it.

For example when you try playing this video( in a

it says

This Video Contains content from Vevo. It is restricted from playback on certain sites

How would I go about getting videos like this to play in an embedded player or a custom player that I would make using
or such. I know this is possible as following app does this. (

Few videos play in browser but in iOS Simulator its showing

This video contains content from SME . It is restricted from playback on certain site

Thanks for all the help!

Answer Source

To play the youtube video using uiwebview:

  1. First check if your youtube URL is played or not in browser. If the video doesn't play in the browser it won't play in the device either

  2. You only check in the device; the video doesn't play in simulator

    - (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 = @""; // 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:@""]];
        [window addSubview:webView];
        [webView release];