1

这是代码:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *musicURL = [NSURL URLWithString:@"http://live-three2.dmd2.ch/buureradio/buureradio.m3u"];

    if([musicURL scheme])
    {
        MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:musicURL];
        if (mp)
        {
            // save the music player object
            self.musicPlayer = mp;
            [mp release];

            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popBack:) name:@"MPMoviePlayerDidExitFullscreenNotification" object:nil];

            // Play the music!
            [self.musicPlayer play];
        }
    }   
}

-(void)popBack:(NSNotification *)note
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

选择器方法永远不会被调用。我只想在电影播放器​​上按下“完成”按钮时弹回根菜单。我在选择器中放了一个 NSLog 来检查它是否被调用,什么都没有。音乐播放得很好。有什么想法吗?

4

1 回答 1

1

这应该工作

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popBack:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
于 2010-06-11T02:09:17.157 回答