Question

I have a view with a web view which loads a YouTube video. I am using the following methods to automatically start the YouTube video when the web view is loaded.

The web view opens the iPhones native movie player. Is there any way to check if the video has ended or the user has pushed the "OK" button of the movie player and the player is thereby closed?

These are the methods I use for automatically starting the web view:

- (UIButton *)findButtonInView:(UIView *)view {
    UIButton *button = nil;

    if([view isMemberOfClass:[UIButton class]]) {
        return (UIButton *)view;
    }

    if(view.subviews && [view.subviews count] > 0) {
        for(UIView *subview in view.subviews) {
            button = [self findButtonInView:subview];
            if(button) return button;
        }
    }

    return button;
}

- (void)webViewDidFinishLoad:(UIWebView *)_webView {
    UIButton *b = [self findButtonInView:_webView];
    [b sendActionsForControlEvents:UIControlEventTouchUpInside];
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top