无法让电影在循环内完成

时间:2015-06-10 13:19:42

标签: ios movie nsnotification activity-finish

我希望电影可以像数组中的对象一样频繁播放,但我想确保电影每次都播放完毕。

这里有一些简单的代码,我希望这样做:

- (void)loopThroughArray {

        [Array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            NSLog (@"Index = %i", idx);

            moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:url];

            [[NSNotificationCenter defaultCenter] addObserver:self
                                                     selector:@selector(moviePlayBackDidFinish:)
                                                         name:MPMoviePlayerPlaybackDidFinishNotification
                                                       object:moviePlayerController];
            [moviePlayerController play];


        }];
    }];

}


- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
    moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:moviePlayerController];

    NSLog(@"Movie playback finished");
}

不幸的是,代码只是在循环中运行,然后播放电影,如日志中所示:

 Index = 0
 Index = 1
 Index = 2
 Index = 3
 Index = 4
 Index = 5
 Movie playback finished

我做错了什么?

感谢您的见解

0 个答案:

没有答案