Ios4 如何获取MPMoviePlayerController的playbackState更改通知

Ios4 如何获取MPMoviePlayerController的playbackState更改通知,ios4,mpmovieplayercontroller,Ios4,Mpmovieplayercontroller,我正在编写一个iPhone应用程序,通过http播放流媒体,下面是我的代码 - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlayba

我正在编写一个iPhone应用程序,通过http播放流媒体,下面是我的代码

- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; //livePlayer is MPMoviePlayerController declared in header livePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString: liveStreamURL]]; livePlayer.controlStyle = MPMovieControlStyleNone; [livePlayer prepareToPlay]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; } - (void) moviePlayerLoadStateChanged:(NSNotification*)notification {      if ([livePlayer loadState] != MPMovieLoadStateUnknown) { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; [livePlayer play]; } } -(void) moviePlayerPlaybackStateDidChange:(NSNotification*)notification { NSLog(@"playbackDidChanged"); MPMoviePlayerController *moviePlayer = notification.object; MPMoviePlaybackState playbackState = moviePlayer.playbackState; if(playbackState == MPMoviePlaybackStateStopped) { NSLog(@"MPMoviePlaybackStateStopped"); } else if(playbackState == MPMoviePlaybackStatePlaying) { NSLog(@"MPMoviePlaybackStatePlaying"); } else if(playbackState == MPMoviePlaybackStatePaused) { NSLog(@"MPMoviePlaybackStatePaused"); } else if(playbackState == MPMoviePlaybackStateInterrupted) { NSLog(@"MPMoviePlaybackStateInterrupted"); } else if(playbackState == MPMoviePlaybackStateSeekingForward) { NSLog(@"MPMoviePlaybackStateSeekingForward"); } else if(playbackState == MPMoviePlaybackStateSeekingBackward) { NSLog(@"MPMoviePlaybackStateSeekingBackward"); } } moviePlayerPlaybackStateDidChange方法仅在开始播放流时调用一次。由于网络状态不好,有时它会停止播放并显示黑屏,我想在缓冲流时显示UIActivityIndicateView,有人能告诉我怎么做吗?
我正在使用SDK4.0

使用MPMovieLoadStateDidChange通知,而不是查找玩家是否饥饿等。工作正常使用MPMovieLoadStateDidChange通知,而不是查找玩家是否饥饿等。工作正常