I would like to remove or disable the seek forward button from the MPMediaPlayer. I have tried to enumerate al开发者_运维百科l the views but apparently I could not find this button.
Does anyone have any idea?
Thanks.
You could always provide a custom control panel, you can hide the default controls with
playerController.controlStyle = MPMovieControlStyleNone;
Then add a subview containing your interface and just link buttons to play/pause start/stop rewinding, and there's an open source implementation of the variable speed slider (OBSlider). You will also need to register for some MP notifications:
MPMovieDurationAvailableNotification
MPMoviePlayerLoadStateDidChangeNotification
MPMoviePlayerPlaybackDidFinishNotification
MPMoviePlayerPlaybackStateDidChangeNotification
The only way I found is to add a transparent button over the seek forward button. Here is the code:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIButton *button = [[UIButton alloc] init];
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
[button setFrame:CGRectMake(535, 599, 90, 60)];
else
[button setFrame:CGRectMake(407, 855, 90, 60)];
[button setBackgroundColor:[UIColor clearColor]];
[button setAlpha:0.7];
[button setTag:1200];
[self.moviePlayer.view addSubview:button];
[button release];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
{
UIButton *button = (UIButton *)[self.moviePlayer.view viewWithTag:1200];
[button setFrame:CGRectMake(535, 599, 90, 60)];
}
else
{
UIButton *button = (UIButton *)[self.moviePlayer.view viewWithTag:1200];
[button setFrame:CGRectMake(407, 855, 90, 60)];
}
}
This is for IPAD ONLY! If you would like to do the same on iPhone, please change the position of the transparent button.
精彩评论