-1

I have done the following - once played a QTMovie (on Mountain Lion) and wanted to get notification when a movie ended. But the notification never got called! Can anybody tell me what have I done wrong?

- (void)playMovie:(QTMovie *)movie {
    [self.movieView.movie stop];

    if (movie) {
        self.movieView.movie = movie;
        [movie gotoBeginning];
        [movie play];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopMovie:) name:QTMovieDidEndNotification object:self];
    }
}


- (void)stopMovie:(NSNotification *)notification {
    NSLog(@"stop movie!");
    [[NSNotificationCenter defaultCenter] removeObserver:self name:QTMovieDidEndNotification object:nil];
}
Lim Thye Chean
  • 8,704
  • 9
  • 49
  • 88

1 Answers1

1

Try changing to the following (note the object parameter):

[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(stopMovie:)
    name:QTMovieDidEndNotification
    object:movie];
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
koan
  • 3,596
  • 2
  • 25
  • 35