Fading out MPMoviePlayerController controls

2019-07-27 03:55发布

问题:

When I start a movie in a MPMoviePlayerController, controls stay at the top for few seconds. After that, they fade out.

I want simulate this effect when I use MPMovieControlStyleNone in controlStyle property, but controls disappear abruptly. I tried to use animations without success with the following code:

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.50f];
        self.myMoviePlayer.controlStyle = MPMovieControlStyleNone;
        [UIView commitAnimations];

Someone have any idea how I can make that?

Any help will be appreciated.

Thanks.

回答1:

If I understand you correctly, you are planning to hide custom controls in a similar fashion to the original controls.

You will need hide your custom controls using something like

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.50];
self.customControlsView.alpha = 0.0f;
[UIView commitAnimations];

to achieve that effect. controlStyle is not an animatable property.

On tops, you will need to stick to controlStyle = MPMovieControlStyleNone anyways throughout the lifetime of your MPMoviePlayerController as that is the only way to prevent the original controls from appearing.