Question

Can anyone suggest me how to obtain the view that contains all buttons from 'MPMoviePlayer'?

If you don't know, at least how you obtain the main view/window of the MPMoviePlayer.

UPDATE: I need to do this to add a button on the controller view. It would look something like this: Example http://img338.imageshack.us/img338/5184/poz.jpg

Thanks in advance!

Was it helpful?

Solution

You can't add it directly to the MPMoviePlayerController's view -- that's a private view and isn't accessible. If you want to add buttons, you need to create a transparent window over the top of everything and add the buttons to that.

Apple's MoviePlayer sample shows how to do this.

OTHER TIPS

The above answer is actually incorrect: the view is not private, and you can add views to it. You just have to dive deep enough to find it.

For example, in iOS 5.1, you can try something like this:

UIView *fullscreenOverlayView = [[[[[[[mpPlayer view] subviews] objectAtIndex:0] subviews] objectAtIndex:0] subviews] objectAtIndex:2];
[fullscreenOverlayView addSubview:ccButton];

This will add a CC button to the view, and if you specify the correct value for the frame of the CC button, it will insert the button to the control panel, and hide/show it with the control panel on touch. FYI: this is the frame I use:

BOOL isPortrait = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation);

// all of these values are just based on measurement on screen
// to make sure that the CC button "seems" to be part of the player's control panel
if (isPortrait)
{
    return CGRectMake(222, 880, 40, 40);
}
else {
    return CGRectMake(350, 625, 40, 40);
}

NOTE: the set of subviews of [mpPlayer view] are different for different iOS versions, so consider this as a work around only. There's no guarantee that this will work on iOS 6, and will crash on iOS 4.3.

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