Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6941449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:53:14+00:00 2026-05-27T12:53:14+00:00

I didn’t received any notifications for MPMoviePlayerController . What am I doing wrong? I

  • 0

I didn’t received any notifications for MPMoviePlayerController. What am I doing wrong?

I use following logic.

I’m begining to play youtube video in UIWebView. UIWebView calls a standard MPMoviePlayerController. I don’t control MPMoviePlayerController because I didn’t instantiate MPMoviePlayerController.

I run youtube’s clip with autoplay (1 second delay):

[self performSelector:@selector(touchInView:) withObject:b afterDelay:1];

My code is:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackDidFinish:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];

    [self embedYouTube];
}

- (void)loadStateDidChange:(NSNotification*)notification
{
    NSLog(@"________loadStateDidChange");
}

- (void)playbackDidFinish:(NSNotification*)notification
{
    NSLog(@"________DidExitFullscreenNotification");
}

- (void)embedYouTube
{
    CGRect frame = CGRectMake(25, 89, 161, 121);
    NSString *urlString = [NSString stringWithString:@"http://www.youtube.com/watch?v=sh29Pm1Rrc0"];

    NSString *embedHTML = @"<html><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, urlString, frame.size.width, frame.size.height];
    UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
    videoView.delegate = self;

    for (id subview in videoView.subviews)
        if ([[subview class] isSubclassOfClass: [UIScrollView class]])
            ((UIScrollView *)subview).bounces = NO;

            [videoView loadHTMLString:html baseURL:nil];
    [self.view addSubview:videoView];
    [videoView release];
}

- (void)webViewDidFinishLoad:(UIWebView *)_webView 
{
    UIButton *b = [self findButtonInView:_webView];
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(touchInView:) object:b];
    [self performSelector:@selector(touchInView:) withObject:b afterDelay:1];
}

- (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)touchInView:(UIButton*)b
{
    [b sendActionsForControlEvents:UIControlEventTouchUpInside];
}

UPDATE: I’m creating application that plays youtube’s video. You can run playlist and you will see first video. When first video has ended, second video begins play automatically and so on.

I need to support ios 4.1 and above.

UPDATE2: @H2CO3 I’m trying to use your url-scheme, but it don’t works. Delegate method didn’t called on exit event. I added my html url to log.
It is:

<html><head>    <body style="margin:0">    
<script>function endMovie() 
{document.location.href="somefakeurlscheme://video-ended";} 
 </script>      <embed id="yt" src="http://www.youtube.com/watch?v=sh29Pm1Rrc0"        
 onended="endMovie()" type="application/x-shockwave-flash"  
 width="161" height="121"></embed>  
 </body></html>

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
  if ([[[request URL] absoluteString] hasPrefix:@"somefakeurlscheme://video-ended"]) 
  {
    [self someMethodSupposedToDetectVideoEndedEvent];
    return NO; // prevent really loading the URL
   }
  return YES; // else load the URL as desired
}

UPDATE3
@Till, I cann’t caught UIMoviePlayerControllerDidExitFullscreenNotification, but I found MPAVControllerItemPlaybackDidEndNotification. MPAVControllerItemPlaybackDidEndNotification appears when playback video is ended.

But I don’t understand how do I catch onDone notifications?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:53:15+00:00Added an answer on May 27, 2026 at 12:53 pm

    There are no documented notifications sent by the UIWebView embedded movie player.

    In fact, the closed implementation used within the UIWebView does differ from the public MPMoviePlayerController in many aspects (e.g. DRM).

    The most important classes used for playing video content within that UIWebView are called MPAVController and UIMoviePlayerController. The latter one makes the player appear like the MPMoviePlayerController fullscreen interface.

    In case you dare to risk a rejection by Apple, there are actually ways to still achieve what you are looking for.

    NOTE
    This is not documented and is subject to break on each and every new iOS release. It does however work on iOS4.3, 5.0 and 5.01, 5.1 and 6.0 and it may work on other versions as well.

    I am not able to test this solution on iOS 4.1 and 4.2, so that is up to you to do. I highly suspect that it will work.


    Fullscreen State

    If, for example you are intending to react upon the user tapping the DONE button, you may be able to do it this way:

    UPDATE The old version of this answer recommended to use UIMoviePlayerControllerDidExitFullscreenNotification whereas this new version (updated for iOS6) recommends using UIMoviePlayerControllerWillExitFullscreenNotification.

    C-Language Level:

    void PlayerWillExitFullscreen (CFNotificationCenterRef center,
                     void *observer,
                     CFStringRef name,
                     const void *object,
                     CFDictionaryRef userInfo)
    {
        //do something...
    }
    
    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), 
        NULL, 
        PlayerWillExitFullscreen, 
        CFSTR("UIMoviePlayerControllerWillExitFullscreenNotification"), 
        NULL,  
        CFNotificationSuspensionBehaviorDeliverImmediately);
    

    Objective-C Level:

    - (void)playerWillExitFullscreen:(NSNotification *)notification
    {
        //do something...
    }
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playerWillExitFullscreen:)
                                                 name:@"UIMoviePlayerControllerWillExitFullscreenNotification" 
                                               object:nil];
    

    I did draft both, C-Level and Objective-C-Level options because the best way to actually find out about all of this is to use C-Level (CoreFoundation) functions as shown at the end of my answer. If the sender of a notification does not use Objective-C (NSNotifications), you may actually not be able to trap them using the NSNotification-mechanics.


    Playback State

    For examining the playback state, look out for "MPAVControllerPlaybackStateChangedNotification" (as drafted above) and examine the userInfo which may look like this:

    {
        MPAVControllerNewStateParameter = 1;
        MPAVControllerOldStateParameter = 2;
    }
    

    Further Reverse Engineering

    For reverse engineering and exploring all the notifications sent, use the following snippet.

    void MyCallBack (CFNotificationCenterRef center,
                     void *observer,
                     CFStringRef name,
                     const void *object,
                     CFDictionaryRef userInfo)
    {
        NSLog(@"name: %@", name);
        NSLog(@"userinfo: %@", userInfo);
    }
    
    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), 
        NULL, 
        MyCallBack, 
        NULL, 
        NULL,  
        CFNotificationSuspensionBehaviorDeliverImmediately);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Didn't find any from their website. I mostly just trying to see which one
I didn't see any similar questions asked on this topic, and I had to
I didn't get any overlay change when my teammates make changes or add a
I didn't change any setting of my Vim, but today the Backspace gets some
I didn't manage to find any functionalities for minimizing/maximizing programatically. I want to minimize
I didn't use subviews but painted my things with -drawRect: inside an UIView subclass.
I didn't use Prototype.js before, when I use jquery, I can get an element
I didn't find any documentation on how to create an aggregation with Layout Style
I didn't find any info on searches when I looked this up. I've been
I didn't write the following code and I am not a Javascript expert. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.