I have an MPMoviePlayerViewController that plays audio. I would like to remove the Quicktime logo and/or add a custom background image to the player but keep the playback controls. I swear I have done this before prior to iOS 5 but I can't re-figure it out! Things I have tried:
-Adding a subview to MPMoviePlayerViewController. Puts the subview OVER the playback controls, not good.
-setBackgroundColor of the moviePlayer with a patternimage. Doesn't do anything.
-setView on the entire MPMoviePlayerViewController. As expected, the playback controls and navigation bar are gone. I suppose this could work but I'd need to recreate all the playback controls manually, but I'd really rather not.
Can anyone shed some light?
Check out the MPMoviePlayerController
property backgroundView
.
From the MPMoviePlayerController Class Reference;
backgroundView
A customizable view that is displayed behind the movie
content. (read-only)
@property (nonatomic, readonly) UIView *backgroundView
Discussion This
view provides the backing content, on top of which the movie content
is displayed. You can add subviews to the background view if you want
to display custom background content.
This view is part of the view hierarchy returned by the view property.
Availability Available in iOS 3.2 and later. Declared In
MPMoviePlayerController.h
Try something like this (assuming that your instance of the MPMoviePlayerController is called moviePlayerController
):
patternView = [[UIView alloc] initWithFrame:self.view.bounds];
patternView.backgroundColor = [UIColor redColor];
[moviePlayerController.backgroundView addSubview:patternView];
[patternView release];
Till's answer is correct for iPhoneOS 3. This has changed in iOS 4 and 5.
Apple has now added a readonly property to MPMoviePlayerViewController exposing a MPMovieController. The MPMovieController has a backgroundView that should be used.
Now you will want to do something like this:
patternView = [[UIView alloc] initWithFrame:self.view.bounds];
patternView.backgroundColor = [UIColor redColor];
[moviePlayerController.moviePlayer.backgroundView addSubview:patternView];
[patternView release];