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 に答える