iPhone-MPMediaPlayer禁用向前搜索按钮

时间:2011-09-29 15:26:04

标签: iphone forward seek mpmediaplayercontroller

我想删除或禁用MPMediaPlayer中的搜索转发按钮。 我试图列举所有的观点,但显然我找不到这个按钮。

有没有人有任何想法?

感谢。

2 个答案:

答案 0 :(得分:0)

您始终可以提供自定义控制面板,您可以使用

隐藏默认控件
playerController.controlStyle = MPMovieControlStyleNone;

然后添加一个包含界面的子视图,只需添加链接按钮即可播放/暂停开始/停止倒带,还有一个变速滑块(OBSlider)的开源实现。您还需要注册一些MP通知:

MPMovieDurationAvailableNotification
MPMoviePlayerLoadStateDidChangeNotification
MPMoviePlayerPlaybackDidFinishNotification
MPMoviePlayerPlaybackStateDidChangeNotification

答案 1 :(得分:-1)

我找到的唯一方法是在搜索转发按钮上添加透明按钮。 这是代码:

- (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)];
    }
}

这仅适用于IPAD!如果您想在iPhone上执行相同操作,请更改透明按钮的位置。