Overlay on top of Streaming MPMoviePlayerController

前端 未结 4 1898
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 03:23

I went through the example from apple \"MoviePlayer on iPhone\"

Im trying to overlay on top of the mpmovieplayercontroller,

it works perfectly with video cli

4条回答
  •  误落风尘
    2020-12-13 03:47

    Previous answer was based on timer. & fixed 5 seconds.

    When Movie player begins, a new window is added to application.

    Use a timer to check weather a new window is added to your application or not.

    When a window ( movie player window ) is added. set notifications.

    -(void)viewDidLoad{
    
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(moviePreloadDidFinish:) 
                                                     name:MPMoviePlayerContentPreloadDidFinishNotification 
                                                   object:nil];
    
        // Register to receive a notification when the movie has finished playing. 
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(moviePlayBackDidFinish:) 
                                                     name:MPMoviePlayerPlaybackDidFinishNotification 
                                                   object:nil];
    
        // Register to receive a notification when the movie scaling mode has changed. 
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(movieScalingModeDidChange:) 
                                                     name:MPMoviePlayerScalingModeDidChangeNotification 
                                                   object:nil];
        videoListController.xmlClassVideoList=t;
        // here ttttt is a timer declared in .h file
        tttttt=[NSTimer scheduledTimerWithTimeInterval:0.5 target:self      selector:@selector(startMy) userInfo:nil repeats:YES];  
    }
    
    -(void)startMy{
        NSArray *windows = [[UIApplication sharedApplication] windows];  
        NSLog(@"%i",[windows count]);
        // depends on your application window
        // it may be 1/2/3
        if ([windows count] > 3) {
            // Locate the movie player window
            [tttttt invalidate];
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWindowChanged:) name:UIWindowDidBecomeKeyNotification object:nil];
        }
    }
    

提交回复
热议问题