Iphone 在moviePlayerController中隐藏活动指示器

Iphone 在moviePlayerController中隐藏活动指示器,iphone,iphone-sdk-3.2,uiactivityindicatorview,mpmovieplayer,Iphone,Iphone Sdk 3.2,Uiactivityindicatorview,Mpmovieplayer,正如您所知,当我使用MPmoviePlayerController播放电影时,电影播放器应该在电影播放器视图的中心显示ActivityIndicator视图。现在,我已经在我的程序中放置了一个自定义的activityIndicatorView,我只想隐藏或删除MPMoviePlayController的activityIndicatorView,可以吗?可以 我想您想做的是在加载电影时显示活动idicator,而不是在播放电影时?我只是假设,然后继续 在SDK 3.2及更高版本中,整个MPMov

正如您所知,当我使用MPmoviePlayerController播放电影时,电影播放器应该在电影播放器视图的中心显示ActivityIndicator视图。现在,我已经在我的程序中放置了一个自定义的activityIndicatorView,我只想隐藏或删除MPMoviePlayController的activityIndicatorView,可以吗?

可以

我想您想做的是在加载电影时显示活动idicator,而不是在播放电影时?我只是假设,然后继续

在SDK 3.2及更高版本中,整个MPMoviePlayerController(和MPMoviePlayerViewController)比以前的版本要好得多。如果您仍然使用MPMOVIEWPLIER控制器,您可能会考虑切换到MPMeVIEWReVIEW控制器(它基本上是一个封装了MPMOVIEWPLER控制器对象的UIVIEW子类)。p> 无论如何,要显示和隐藏UIActivityindicator视图,我建议您在加载或播放状态更改时连接从MPMoviePlayerController发送的通知

其中一些是:

MPMoviePlayerPlaybackStateDidChangeNotification
MPMoviePlayerLoadStateDidChangeNotification 
因此,您可以通过以下方式连接到这些事件:

[[NSNotificationCenter defaultCenter] addObserver: self 
                                             selector: @selector(loadStateChanged:) 
                                                 name: MPMoviePlayerLoadStateDidChangeNotification 
                                               object: moviePlayerViewController.moviePlayer];
还有这个

[[NSNotificationCenter defaultCenter] addObserver: self 
                                             selector: @selector(playBackStateChanged:) 
                                                 name: MPMoviePlayerPlaybackStateDidChangeNotification 
                                               object: moviePlayerViewController.moviePlayer];
在处理程序中(
playBackStateChanged
loadStateChanged

您可以这样做:

-(void)playBackStateChanged:(id)sender
{
    MPMoviePlaybackState playbackState = [moviePlayerViewController.moviePlayer playbackState];

    switch (playbackState) {

        case MPMoviePlaybackStateStopped :


            break;

        case MPMoviePlaybackStatePlaying :
            [yourActivityIndicatorView stopAnimating];
            break;

        case MPMoviePlaybackStateInterrupted :
            [yourActivityIndicatorView startAnimating];
            break;
    }
}
确保IndicatorView的“hidesWhenStopped”(或类似)属性设置为yes(如果这样做,则不必关心隐藏和取消隐藏控件)

剩下的很简单,只需将activityIndicatorView添加到MPMovieViewController视图的顶部即可

希望我能帮忙
干杯

sam

我已经这么做了,我想要的只是让MoviePlayService控制器的activeIndicator永远不显示,因为我自己已经添加了一个activeIndicator。我想我现在理解你了。解决方案是隐藏你的播放器,直到Movieplayer的Loadstate等于MPMovieLoadStatePlayable,然后再次取消隐藏播放器。在每次您都可以显示自定义加载程序。