Viewing YouTube video inside app with return to previous ViewControlloer
===

I'm trying to integrate in my app a youtube video. But I want it to resume to the calling viewController when video finished. I've succeeded to almost implement that but in my way the user must press done button and then another to get back to the original ViewController.

This is the code I use, Please help, I prefer with ref to full code.


YouTubeView.h :

    #import <UIKit/UIKit.h>

    @interface YouTubeView : UIWebView
    {
    }

    - (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame mimeSubType:(NSString *)mimeType;
    @end



YouTubeView.m :

    #import "YouTubeView.h"

    @interface YouTubeView ()

    @end

    @implementation YouTubeView


    - (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame mimeSubType:(NSString *)mimeType
    {
    NSString *strMimeType;
    
    if([mimeType length]>0)
    {
        strMimeType = mimeType;
    }
    
    else
    {
        strMimeType =@"x-shockwave-flash"; //@"x-shockwave-mp4";
    }
    
    if (self = [super init])
    {
        // Create webview with requested frame size
        self = [[UIWebView alloc] initWithFrame:frame];
        
        // HTML to embed YouTube video
        
        NSString *videoHTML = [NSString stringWithFormat:@"\
                     <html>\
                     <head>\
                     <style type=\"text/css\">\
                     iframe {position:absolute; top:50%%; margin-top:-130px;}\
                     body {background-color:#000; margin:0;}\
                     </style>\
                     </head>\
                     <body>\
                     <iframe width=\"100%%\" height=\"240px\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>\
                     </body>\
                     </html>", urlString];
        
        [self loadHTMLString:videoHTML baseURL:nil];
        
    }
    
    return self;
    
    }


    - (void)dealloc
    {
    [super dealloc];
    }

    @end


And a button that points to *on main ViewController :
    -(IBAction)runTestVideo:(id)sender {
   
    NSString *strNormalVdoURL = [NSString stringWithFormat:@"http://www.youtube.com/embed/TgLqH9n57B0"];
    
    YouTubeView *videoVw = [[YouTubeView alloc] initWithStringAsURL:[NSString stringWithFormat:@"%@",strNormalVdoURL] frame:CGRectMake(0,0,315,420) mimeSubType:@"x-shockwave-flash"];
                            
                            [self.view addSubview:videoVw];
                            [videoVw release];
                            videoVw = nil;

    }


