Search code examples
iosuiviewuiimageviewmpmovieplayercontroller

MPMoviePlayerController view under another view


If I do this:

self.productVideo = [[MPMoviePlayerController alloc] initWithContentURL:movieClip];
self.productVideo.controlStyle = MPMovieControlStyleNone;
self.productVideo.shouldAutoplay = YES;
[self.productVideo prepareToPlay];
self.productVideo.repeatMode = MPMovieRepeatModeOne;
self.productVideo.view.frame = self.productImage.frame;
self.productVideo.view.userInteractionEnabled = NO;

[self.view insertSubview:productVideo.view belowSubview:self.productImage];

The movie appears on top of the image, when I'm clearly adding it below the image. Is it not possible to have an overlay image on top of a movie?


Solution

  • You could try adding the image view to the mp.view and then you add the mp.view. Something like below:

    self.productVideo = [[MPMoviePlayerController alloc] initWithContentURL:movieClip];
    self.productVideo.controlStyle = MPMovieControlStyleNone;
    self.productVideo.shouldAutoplay = YES;
    [self.productVideo prepareToPlay];
    self.productVideo.repeatMode = MPMovieRepeatModeOne;
    self.productVideo.view.frame = self.productImage.frame;
    self.productVideo.view.userInteractionEnabled = NO;
    [;self.productVide.view addSubView:self.productImage]
    
    [self.view addSubview:productVideo.view];
    

    Is this what you are trying to accomplish?

    If you then intend to hide the image when the video starts or something like that, you probably can not use image.hidden = YES and image.hidden = NO. Then you will have to resort to changing the alpha value of the image, I hear this works well for some.