Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

UIWebView YouTube player, how to detect the end of a movie? on ipad

ciaoduciaodu Posts: 3New Users
edited February 2012 in iPhone SDK Development


Hey fellow developers. ;)



My question is this, how would one go about getting an "end of movie notification" on a embedded youtube video?

I have embedded a Youtube video in a webview, i followed this tutorial. this is the code ::
- (void)embedYouTube:(NSString*)url frame:(CGRect)frame {  

 NSString* embedHTML = @"\<html><head>\<style type=\"text/css\">\body {\background-color: transparent;\color: white;\ 
 }\</style>\</head><body style=\"margin:0\">\<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \width=\"%0.0f\" height=\"%0.0f\"></embed>\</body></html>"; 


 NSString* html = [NSString stringWithFormat:embedHTML, url,frame.size.width, frame.size.height];  
 
if(videoView == nil) {  
   videoView = [[UIWebView alloc] initWithFrame:frame];  
   [self.view addSubview:videoView];  
 }
  
 [videoView loadHTMLString:html baseURL:nil];  
}

i read in this post how to get "end of movie notfication" on the iphone. But this method dosen't work on the ipad(cause it dosent open in the native mpmovieplayer, it opens directly in the webview).

this is the code for getting notification on iphone:
- (void)viewDidLoad
{
    [super viewDidLoad];
 
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(windowNowHidden:)
     name:UIWindowDidBecomeHiddenNotification
     object:self.view.window
     ];
    
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(windowNowVisible:)
     name:UIWindowDidBecomeVisibleNotification
     object:self.view.window
     ];
    
}

- (void)windowNowVisible:(NSNotification *)note
{
    NSLog(@"YouTube window went away");
}

- (void)windowNowHidden:(NSNotification *)note{
    NSLog(@"YouTube window took over");

}

is there any ways of getting the "e.o.m. notfication" when the embedded movie is done playing in the webview?

i need this bad amigos! :confused:

best regards
Ciaodu
Post edited by ciaodu on

Replies

Sign In or Register to comment.