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

- (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