Play youtube video in iOS app

Youtube video can be played in iOS app using webview. MPMoviePlayerController is not able to open youtube video automatically. Integrate the below script to show thumbnail, clicking on it the video will play in full screen.

    NSString *url = @"";
    NSString* embedHTML = @"\
    <style type=\"text/css\">\
    body {\
    background-color: transparent;\
    color: white;\
    </head><body style=\"margin:0\">\
    <iframe id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\" frameborder=\"0\" feature=player_detailpage allowfullscreen></iframe>\
    NSString* html = [NSString stringWithFormat:embedHTML, url, self.view.frame.size.width, 200.0];

    [webview loadHTMLString:html baseURL:nil];


Popular posts from this blog

Exception Handling - Objective C

Vector graphics in iOS

How to show activity indicator in watch kit